Part Number Hot Search : 
I1015 58X25 N121D 4744A BA8274 AD7656 BA8274 AP410
Product Description
Full Text Search
 

To Download HT66F15 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  enhanced a/d flash type mcu ht66f13/ht66f14/HT66F15 revision: 1.10 date: february 9, 2011
table of contents features ...............................................................................................6 c pu features ........................................................................................................6 peripheral features ................................................................................................6 general description ............................................................................7 selection table ....................................................................................7 block diagram .....................................................................................8 pin assignment ...................................................................................9 pin description ..................................................................................10 ht66f13 ..............................................................................................................10 ht66f14 ..............................................................................................................11 HT66F15 ..............................................................................................................12 absolute maximum ratings .............................................................13 d.c. characteristics ..........................................................................13 a.c. characteristics ..........................................................................15 a/d converter characteristics .........................................................16 power-on reset characteristics ......................................................17 system architecture .........................................................................18 clocking and pipelining ........................................................................................18 program counter..................................................................................................19 stack ....................................................................................................................19 arithmetic and logic unit - alu ...........................................................................20 flash program memory ....................................................................21 structure...............................................................................................................21 special vectors.....................................................................................................21 look-up table.......................................................................................................21 table program example .......................................................................................22 in circuit programming.........................................................................................23 ram data memory.............................................................................24 structure...............................................................................................................24 special function register description ...........................................26 indirect addressing registers - iar0, iar1..........................................................26 memory pointers - mp0, mp1 ..............................................................................26 accumulator - acc ..............................................................................................27 contents rev. 1.10 2 february 9, 2011
program counter low register - pcl..................................................................27 look-up table registers - tblp, tbhp, tblh.....................................................27 status register - status ...................................................................................27 oscillator............................................................................................29 oscillator overview...............................................................................................29 system clock configurations................................................................................29 external crystal/ ceramic oscillator - hxt ..........................................................30 external rc oscillator - erc ...............................................................................31 internal rc oscillator - hirc ...............................................................................31 internal 32khz oscillator - lirc...........................................................................31 supplementary oscillator......................................................................................31 operating modes and system clocks .............................................32 system clocks......................................................................................................32 system operation modes .....................................................................................32 control register ...................................................................................................34 fast wake-up .......................................................................................................35 operating mode switching ...............................................................36 normal mode to slow mode switching...........................................................37 slow mode to normal mode switching...........................................................38 entering the sleep0 mode..................................................................................39 entering the sleep1 mode..................................................................................39 entering the idle0 mode .....................................................................................39 entering the idle1 mode .....................................................................................40 standby current considerations...........................................................................40 wake-up...............................................................................................................40 programming considerations ...............................................................................41 watchdog timer ................................................................................41 watchdog timer clock source .............................................................................41 watchdog timer control register.........................................................................42 watchdog timer operation...................................................................................42 reset and initialisation .....................................................................44 reset functions ...................................................................................................44 reset initial conditions .........................................................................................47 input/output ports.............................................................................53 i/o register list....................................................................................................53 pull-high resistors................................................................................................55 port a wake-up ....................................................................................................56 i/o port control registers.....................................................................................57 i/o pin structures .................................................................................................58 programming considerations ...............................................................................58 rev. 1.10 3 february 9, 2011 contents
timer modules - tm..........................................................................59 introduction ..........................................................................................................59 tm operation .......................................................................................................60 tm clock source..................................................................................................60 tm interrupts ........................................................................................................60 tm external pins ....................................................................................................6 tm input/output pin control registers .................................................................61 programming considerations ...............................................................................66 compact type tm - ctm..................................................................67 compact tm operation ........................................................................................67 compact type tm register description ...............................................................68 compact type tm operating modes ....................................................................72 standard type tm - stm..................................................................77 standard tm operation ........................................................................................77 standard type tm register description ...............................................................78 standard type tm operating modes....................................................................82 enhanced type tm - etm ................................................................89 enhanced tm operation ......................................................................................89 enhanced type tm register description..............................................................90 enhanced type tm operating modes ..................................................................95 compare output mode .........................................................................................96 capture input mode............................................................................................107 analog to digital converter............................................................109 a/d overview .....................................................................................................109 a/d converter register description ....................................................................109 a/d converter data registers - adrl, adrh ...................................................110 a/d converter control registers - adcr0, adcr1, acer ...............................110 a/d operation.....................................................................................................113 a/d input pins.....................................................................................................114 summary of a/d conversion steps ....................................................................115 programming considerations .............................................................................116 a/d transfer function.........................................................................................116 a/d programming example ................................................................................117 interrupts..........................................................................................119 interrupt registers ..............................................................................................119 interrupt operation .............................................................................................124 external interrupt ................................................................................................126 multi-function interrupt ........................................................................................126 a/d converter interrupt.......................................................................................127 time base interrupts ..........................................................................................127 lvd interrupt ......................................................................................................128 tm interrupts ......................................................................................................128 contents rev. 1.10 4 february 9, 2011
interrupt wake-up function ................................................................................129 programming considerations .............................................................................129 power down mode and wake-up ...................................................130 entering the idle or sleep mode.....................................................................130 standby current considerations.........................................................................130 wake-up.............................................................................................................130 low voltage detector - lvd ...........................................................131 lvd register ......................................................................................................131 lvd operation....................................................................................................132 scom function for lcd .................................................................132 lcd operation ...................................................................................................132 lcd bias control................................................................................................133 configuration options ....................................................................134 application circuits ........................................................................134 instruction set .................................................................................135 introduction.........................................................................................................135 instruction timing ...............................................................................................135 moving and transferring data ............................................................................135 arithmetic operations .........................................................................................135 logical and rotate operations ...........................................................................135 branches and control transfer...........................................................................136 bit operations.....................................................................................................136 table read operations.......................................................................................136 other operations................................................................................................136 instruction set summary ....................................................................................137 instruction definition ......................................................................139 package information .......................................................................149 16-pin dip (300mil) outline dimensions .............................................................149 16-pin nsop (150mil) outline dimensions .........................................................152 16-pin ssop (150mil) outline dimensions .........................................................153 20-pin dip (300mil) outline dimensions .............................................................154 20-pin sop (300mil) outline dimensions............................................................156 20-pin ssop (150mil) outline dimensions .........................................................157 24-pin skdip (300mil) outline dimensions ........................................................158 24-pin sop (300mil) outline dimensions............................................................161 24-pin ssop (150mil) outline dimensions .........................................................162 28-pin skdip (300mil) outline dimensions ........................................................163 28-pin sop (300mil) outline dimensions............................................................164 28-pin ssop (150mil) outline dimensions .........................................................165 reel dimensions ................................................................................................166 carrier tape dimensions ....................................................................................168 rev. 1.10 5 february 9, 2011 contents
features cpu features operating voltage: f sys = 8mhz: 2.2v~5.5v f sys = 12mhz: 2.7v~5.5v f sys = 20mhz: 4.5v~5.5v up to 0.2 m s instruction cycle with 20mhz system clock at v dd =5v power down and wake-up functions to reduce power consumption four oscillators: e xternal crystal -- hxt external rc -- erc internal rc -- hirc internal 32khz rc -- lirc multi-mode operation: normal, slow, idle and sleep fully integrated internal 4mhz, 8mhz and 12mhz oscillator re quires no external components all instructions executed in one or two instruction cycles table read instructions 63 powerful instructions up to 8-level subroutine nesting bit manipulation instruction peripheral features flash program memory: 1k 1 4 ~ 4k 15 ram data memory: 64 8 ~ 192 8 watchdog timer function up to 26 bidirectional i/o lines software controlled 4-scom lines lcd driver with 1 / 2 bias multiple pin-shared external interrupts multiple timer module for time measure, input capture, compa re match output, pwm output or single pulse output function single time-base function for generation of fixed time inter rupt signal 4 channels 12-bit a/d converter low voltage reset function low voltage detect function wide range of available package types rev. 1.10 6 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
general description the ht66f1x series of devices are flash memory a/d type 8-bit h igh performance risc architecture microcontrollers. offering users the convenience of flash memory multi-programming features, these devices also include a wide range of functions and features. other memory includes an area of ram data memory for application program data storage. analog feature includes a multi-channel 12-bit a/d converter. multiple and extremely flexible timer modules provide timing, pulse generation and pwm generation functions. protective features such as an internal watchdog timer, low voltage reset and low voltage detector coupled with excellent noise immunity and esd protection ensure that reliable operation is maintained in hostile electrical environments. a full choice of hxt, erc, hirc and lirc oscillator functions are provided including a fully integrated system oscillator which requires no external components for its implementation. the ability to operate and switch dynamically between a range of operating modes using different clock sources gives users the ability to optimise microcontroller operation and minimise power consumption. the inclusion of flexible i/o programming features, time-base functions along with many other features ensure that the devices will find excellent use in applications such as electronic metering, environmental monitoring, handheld instruments, household appliances, electronically controlled tools, motor driving in addition to many others. selection table most features are common to all devices, the main feature dist inguishing them are memory capacity, i/o count, tm features, stack capacity and package types. the following table summarises the main features of each device. part no. vdd program memory data memory i/o ext. int. a/d timer module stack package ht66f13 2.2v~ 5.5v 1k 14 648 18 2 12-bit4 10-bit stm1 4 16dip/nsop/ssop 20dip/sop/ssop ht66f14 2.2v~ 5.5v 2k 15 968 22 2 12-bit4 10-bit ctm 1 10-bit stm1 4 16dip/nsop/ssop 20dip/sop/ssop 24skdip/sop/ssop HT66F15 2.2v~ 5.5v 4k 15 1288 26 2 12-bit4 10-bit ctm 1 10-bit etm 1 8 16dip/nsop/ssop 20dip/sop/ssop 24/28skdip/sop/ssop note: as devices exist in more than one package format, the table reflects the situation for the package with the most pins. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 7 february 9, 2011
block diagram rev. 1.10 8 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu w a t c h d o g t i m e r 8 - b i t r i s c m c u c o r e r e s e t c i r c u i t i n t e r r u p t c o n t r o l l e r e r c / h x t o s c i l l a t o r 1 2 - b i t a / d c o n v e r t e r l i r c o s c i l l a t o r h i r c o s c i l l a t o r r a m d a t a m e m o r y l o w v o l t a g e r e s e t l o w v o l t a g e d e t e c t t m 1 t m 0 f l a s h m e m o r y p r o g r a m m i n g c i r c u i t r y ( i c p ) f l a s h p r o g r a m m e m o r y t i m e b a s e i / o
pin assignment ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 9 february 9, 2011 1 6 1 5 1 4 1 3 1 2 1 1 1 0 9 1 2 3 4 5 6 7 8 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 2 3 4 5 6 7 8 9 1 0 p a 0 / a n 0 p a 1 / a n 1 p a 2 / a n 2 p a 3 / a n 3 p a 4 p a 5 p a 6 / t c k 1 p a 7 / t p 1 _ 0 p b 0 / v r e f v s s p b 1 / o s c 1 p b 2 / o s c 2 v d d p b 3 / r e s p b 4 / i n t 0 p b 5 / i n t 1 h t 6 6 f 1 3 1 6 d i p - a / n s o p - a / s s o p - a p a 0 / a n 0 p a 1 / a n 1 p a 2 / a n 2 p a 3 / a n 3 p a 4 p a 5 p a 6 / t c k 1 p a 7 / t p 1 _ 0 p c 1 / s c o m 1 p c 0 / s c o m 0 p b 0 / v r e f v s s p b 1 / o s c 1 p b 2 / o s c 2 v d d p b 3 / r e s p b 4 / i n t 0 p b 5 / i n t 1 p b 6 / t p 1 _ 1 / s c o m 2 p b 7 / s c o m 3 h t 6 6 f 1 3 2 0 d i p - a / s o p - a / s s o p - a 1 6 1 5 1 4 1 3 1 2 1 1 1 0 9 1 2 3 4 5 6 7 8 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 2 3 4 5 6 7 8 9 1 0 p a 0 / a n 0 p a 1 / a n 1 p a 2 / a n 2 p a 3 / a n 3 p a 4 / t c k 0 p a 5 / t p 0 _ 0 p a 6 / t c k 1 p a 7 / t p 1 _ 0 p b 0 / v r e f v s s p b 1 / o s c 1 p b 2 / o s c 2 v d d p b 3 / r e s p b 4 / i n t 0 p b 5 / i n t 1 h t 6 6 f 1 4 1 6 d i p - a / n s o p - a / s s o p - a p a 0 / a n 0 p a 1 / a n 1 p a 2 / a n 2 p a 3 / a n 3 p a 4 / t c k 0 p a 5 / t p 0 _ 0 p a 6 / t c k 1 p a 7 / t p 1 _ 0 p c 1 / t p 0 _ 1 / s c o m 1 p c 0 / s c o m 0 p b 0 / v r e f v s s p b 1 / o s c 1 p b 2 / o s c 2 v d d p b 3 / r e s p b 4 / i n t 0 p b 5 / i n t 1 p b 6 / t p 1 _ 1 / s c o m 2 p b 7 / s c o m 3 h t 6 6 f 1 4 2 0 d i p - a / s o p - a / s s o p - a h t 6 6 f 1 4 2 4 s k d i p - a / s o p - a / s s o p - a 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 p b 0 / v r e f v s s p b 1 / o s c 1 p b 2 / o s c 2 v d d p b 3 / r e s p b 4 / i n t 0 p b 5 / i n t 1 p d 0 p d 1 p b 6 / t p 1 _ 1 / s c o m 2 p b 7 / s c o m 3 p a 0 / a n 0 p a 1 / a n 1 p a 2 / a n 2 p a 3 / a n 3 p a 4 / t c k 0 p a 5 / t p 0 _ 0 p a 6 / t c k 1 p a 7 / t p 1 _ 0 p c 3 p c 2 p c 1 / t p 0 _ 1 / s c o m 1 p c 0 / s c o m 0 1 6 1 5 1 4 1 3 1 2 1 1 1 0 9 1 2 3 4 5 6 7 8 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 2 3 4 5 6 7 8 9 1 0 p b 2 / o s c 2 p b 1 / o s c 1 v s s p b 0 / v r e f p a 0 / a n 0 p a 1 / a n 1 p a 3 / a n 3 p a 2 / a n 2 v d d p b 4 / i n t 0 p b 5 / i n t 1 p b 3 / r e s p a 5 / t p 0 _ 0 p a 7 / t p 1 b _ 0 p a 6 / t c k 1 p a 4 / t c k 0 h t 6 6 f 1 5 1 6 d i p - a / n s o p - a / s s o p - a h t 6 6 f 1 5 2 0 d i p - a / s o p - a / s s o p - a p a 0 / a n 0 p a 1 / a n 1 p a 2 / a n 2 p a 3 / a n 3 p a 4 / t c k 0 p a 5 / t p 0 _ 0 p a 6 / t c k 1 p a 7 / t p 1 b _ 0 p c 1 / t p 0 _ 1 / s c o m 1 p c 0 / t p 1 a / s c o m 0 p b 0 / v r e f v s s p b 1 / o s c 1 p b 2 / o s c 2 v d d p b 3 / r e s p b 4 / i n t 0 p b 5 / i n t 1 p b 6 / t p 1 b _ 1 / s c o m 2 p b 7 / t p 1 b _ 2 / s c o m 3 p b 0 / v r e f v s s p b 1 / o s c 1 p b 2 / o s c 2 v d d p b 3 / r e s p b 4 / i n t 0 p b 5 / i n t 1 p d 0 p d 1 p b 6 / t p 1 b _ 1 / s c o m 2 p b 7 / t p 1 b _ 2 / s c o m 3 h t 6 6 f 1 5 2 4 s k d i p - a / s o p - a / s s o p - a 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 p a 0 / a n 0 p a 1 / a n 1 p a 2 / a n 2 p a 3 / a n 3 p a 4 / t c k 0 p a 5 / t p 0 _ 0 p a 6 / t c k 1 p a 7 / t p 1 b _ 0 p c 3 p c 2 p c 1 / t p 0 _ 1 / s c o m 1 p c 0 / t p 1 a / s c o m 0 2 8 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 p a 0 / a n 0 p a 1 / a n 1 p a 2 / a n 2 p a 3 / a n 3 p a 4 / t c k 0 p a 5 / t p 0 _ 0 p a 6 / t c k 1 p a 7 / t p 1 b _ 0 p c 5 p c 4 p c 3 p c 2 p c 1 / t p 0 _ 1 / s c o m 1 p c 0 / t p 1 a / s c o m 0 p b 0 / v r e f v s s p b 1 / o s c 1 p b 2 / o s c 2 v d d p b 3 / r e s p b 4 / i n t 0 p b 5 / i n t 1 p c 6 p c 7 p d 0 p d 1 p b 6 / t p 1 b _ 1 / s c o m 2 p b 7 / t p 1 b _ 2 / s c o m 3 h t 6 6 f 1 5 2 8 s k d i p - a / s o p - a / s s o p - a
pin description with the exception of the power pins, all pins on these devices can be referenced by their port name, e.g. pa.0, pa.1 etc, which refer to the digital i/o function of the pins. however some of these port pins are also shared with other function such as the analog to digital converter, timer module pins etc. the function of each pin is listed in the following table, however the details behind how each pin is configured is contained in other sections of the datasheet. ht66f13 pin name function op i/t o/t pin-shared mapping pa0~pa7 port a pawu papu st cmos ? pb0~pb7 port b pbpu st cmos ? pc0~pc1 port c pcpu st cmos ? an0~an3 a/d converter input acer an ? pa0~pa3 vref a/d converter reference input adcr1 an ? pb0 tck1 tm1 input ? st ? pa6 tp1_0, tp1_1 tm1 i/o tmpc st cmos pa7, pb6 int0, int1 ext. interrupt 0, 1 ? st ? pb4, pb5 scom0~scom3 scom0~scom3 scomc ? scom pc0, pc1, pb6, pb7 osc1 hxt/erc pin co hxt ? pb1 osc2 hxt pin co ? hxt pb2 res reset pin co st ? pb3 vdd power supply * ? pwr ? ? vss ground * ? pwr ? ? note: i/t: input type o/t: output type op: optional by configuration option (co) or register option pwr: power co: configuration option st: schmitt trigger input cmos: cmos output scom: software controlled lcd com an: analog input pin hxt: high frequency crystal oscillator *: avdd is the adc power supply and is bonded together internally with vdd while avss is the adc ground pin and is bonded together internally with vss. rev. 1.10 10 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
ht66f14 pin name function op i/t o/t pin-shared mapping pa0~pa7 port a pawu papu st cmos ? pb0~pb7 port b pbpu st cmos ? pc0~pc3 port c pcpu st cmos ? pd0~pd1 port d pdpu st cmos ? an0~an3 a/d converter input acer an ? pa0~pa3 vref a/d converter reference input adcr1 an ? pb0 tck0, tck1 tm0, tm1 input ? st ? pa4, pa6 tp0_0, tp0_1 tm0 i/o tmpc st cmos pa5, pc1 tp1_0, tp1_1 tm1 i/o tmpc st cmos pa7, pb6 int0, int1 ext. interrupt 0, 1 ? st ? pb4, pb5 scom0~scom3 scom0~scom3 scomc ? scom pc0, pc1, pb6, pb7 osc1 hxt/erc pin co hxt ? pb1 osc2 hxt pin co ? hxt pb2 res reset pin co st ? pb3 vdd power supply * ? pwr ? ? vss ground * ? pwr ? ? note: i/t: input type i/t: input type o/t: output type op: optional by configuration option (co) or register option pwr: power co: configuration option st: schmitt trigger input cmos: cmos output scom: software controlled lcd com an: analog input pin hxt: high frequency crystal oscillator *: avdd is the adc power supply and is bonded together internally with vdd while avss is the adc ground pin and is bonded together internally with vss. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 11 february 9, 2011
HT66F15 pin name function op i/t o/t pin-shared mapping pa0~pa7 port a pawu papu st cmos ? pb0~pb7 port b pbpu st cmos ? pc0~pc7 port c pcpu st cmos ? pd0~pd1 port d pdpu st cmos ? an0~an3 a/d converter input acer an ? pa0~pa3 vref a/d converter reference input adcr1 an ? pb0 tck0, tck1 tm0, tm1 input ? st ? pa4, pa6 tp0_0, tp0_1 tm0 i/o tmpc st cmos pa5, pc1 tp1a tm1 i/o tmpc st cmos pc0 tp1b_0, tp1b_1, tp1b_2 tm1 i/o tmpc st cmos pa7, pb6, pb7 int0, int1 ext. interrupt 0, 1 ? st ? pb4, pb5 scom0~scom3 scom0~scom3 scomc ? scom pc0, pc1, pb6, pb7 osc1 hxt/erc pin co hxt ? pb1 osc2 hxt pin co ? hxt pb2 res reset pin co st ? pb3 vdd power supply * ? pwr ? ? vss ground * ? pwr ? ? note: i/t: input type o/t: output type op: optional by configuration option (co) or register option pwr: power co: configuration option st: schmitt trigger input cmos: cmos output scom: software controlled lcd com an: analog input pin hxt: high frequency crystal oscillator *: avdd is the adc power supply and is bonded together internally with vdd while avss is the adc ground pin and is bonded together internally with vss. rev. 1.10 12 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
absolute maximum ratings supply voltage ...............................................................................................v ss -0.3v to v ss +6.0v input v oltage .................................................................................................v ss -0.3v to v dd +0.3v storage t emperature ................................................................................................. -50c to 125c operating temperature................................................................................................ -40c to 85c i ol total...................................................................................................................................100ma i oh total ................................................................................................................................ -100ma t otal power dissipation .........................................................................................................500mw note: these are stress ratings only. stresses exceeding the range specified under 2 absolute maximum rat - ings 2 may cause substantial damage to the device. functional operation of this device at other condi - tions beyond those listed in the specification is not implied and prolonged exposure to extreme conditions may affect device reliability. d.c. characteristics t a=25c symbol parameter test conditions min. typ. max. unit v dd conditions v dd operating voltage (hxt, erc, hirc) ? f sys =8mhz 2.2 ? 5.5 v f sys =12mhz 2.7 ? 5.5 v f sys =20mhz 4.5 ? 5.5 v i dd1 operating current, normal mode, f sys =f h (hxt, erc, hirc) 3v no load, f sys =f h =4mhz, adc off, wdt enable ? 0.7 1.1 ma 5v ? 1.8 2.7 ma 3v no load, f sys =f h =8mhz, adc off, wdt enable ? 1.6 2.4 ma 5v ? 3.3 5.0 ma 3v no load, f sys =f h =12mhz, adc off, wdt enable ? 2.2 3.3 ma 5v ? 5.0 7.5 ma i dd2 operating current, normal mode, f sys =f h (hxt) 5v no load, f sys =f h =20mhz, adc off, wdt enable ? 6.0 9.0 ma i dd3 operating current, slow mode, f sys =f l (lirc) 3v no load, f sys =f l , adc off, wdt enable ? 10 20 ma 5v ? 30 50 ma i idle0 idle0 mode standby current (lirc on) 3v no load, adc off, wdt enable ? 1.5 3.0 ma 5v ? 3.0 6.0 ma i idle1 idle1 mode standby current (hxt, erc, hirc) 3v no load, adc off, wdt enable, f sys =12mhz on ? 0.55 0.83 ma 5v ? 1.30 2.00 ma i sleep0 sleep0 mode standby current (lirc off) 3v no load, adc off, wdt disable ? ? 1 ma 5v ? ? 2 ma i sleep1 sleep1 mode standby current (lirc on) 3v no load, adc off, wdt enable ? 1.5 3.0 ma 5v ? 2.5 5.0 ma v il1 input low voltage for i/o ports or input pins except res pin ? ? 0 ? 0.2v dd v 5v ? 0 ? 1.5 v ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 13 february 9, 2011
symbol parameter test conditions min. typ. max. unit v dd conditions v ih1 input high voltage for i/o ports or input pins except res pin ? ? 0.8v dd ? v dd v 5v ? 3.5 ? 5.0 v v il2 input low voltage (res ) ? ? 0 ? 0.4v dd v v ih2 input high voltage (res ) ? ? 0.9v dd ? v dd v v lvr lvr voltage level ? lvr enable, 2.10v option -5% 2.10 +5% v lvr enable, 2.55v option -5% 2.55 +5% v lvr enable, 3.15v option -5% 3.15 +5% v lvr enable, 4.20v option -5% 4.20 +5% v v lvd lvd voltage level ? lvden=1, v lvd =2.0v -5% 2.00 +5% v lvden=1, v lvd =2.2v -5% 2.20 +5% v lvden=1, v lvd =2.4v -5% 2.40 +5% v lvden=1, v lvd =2.7v -5% 2.70 +5% v lvden=1, v lvd =3.0v -5% 3.00 +5% v lvden=1, v lvd =3.3v -5% 3.30 +5% v lvden=1, v lvd =3.6v -5% 3.60 +5% v lvden=1, v lvd =4.4v -5% 4.40 +5% v i lv additional power consumption if lvr and lvd is used ? lvr enable, lvden=0 ? 60 90 ma lvr disable, lvden=1 ? 75 115 ma lvr enable, lvden=1 ? 90 135 ma v ol output low voltage i/o port 3v i ol =9ma ? ? 0.3 v 5v i ol =20ma ? ? 0.5 v v oh output high voltage i/o port 3v i oh =-3.2ma 2.7 ? ? v 5v i oh =-7.4ma 4.5 ? ? v r ph pull-high resistance for i/o ports 3v ? 20 60 100 kw 5v 10 30 50 kw i scom scom operating current 5v scomc, isel[1:0]=00 17.5 25.0 32.5 ma scomc, isel[1:0]=01 35 50 65 ma scomc, isel[1:0]=10 70 100 130 ma scomc, isel[1:0]=11 140 200 260 ma v scom v dd /2 voltage for lcd com 5v no load 0.475 0.500 0.525 v dd v 125 1.25v reference with buffer voltage ? ? -3% 1.25 +3% v i 125 additional power consumption if 1.25v reference with buffer is used ? ? ? 200 300 ma rev. 1.10 14 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
a.c. characteristics ta=25 c symbol parameter test conditions min. typ. max. unit v dd conditions f cpu operating clock ? 2.2v~5.5v dc ? 8 mhz 2.7v~5.5v dc ? 12 mhz 4.5v~5.5v dc ? 20 mhz f sys system clock (hxt) ? 2.2v~5.5v 0.4 ? 8 mhz 2.7v~5.5v 0.4 ? 12 mhz 4.5v~5.5v 0.4 ? 20 mhz f hirc system clock (hirc) 3v/5v ta=25c -2% 4 +2% mhz 3v/5v ta=25c -2% 8 +2% mhz 5v ta=25c -2% 12 +2% mhz 3v/5v ta=0~70c -5% 4 +5% mhz 3v/5v ta=0~70c -4% 8 +4% mhz 5v ta=0~70c -5% 12 +3% mhz 2.2v~ 3.6v ta=0~70c -7% 4 +7% mhz 3.0v~ 5.5v ta=0~70c -5% 4 +9% mhz 2.2v~ 3.6v ta=0~70c -6% 8 +4% mhz 3.0v~ 5.5v ta=0~70c -4% 8 +9% mhz 3.0v~ 5.5v ta=0~70c -6% 12 +7% mhz 2.2v~ 3.6v ta= -40c~85c -12% 4 +8% mhz 3.0v~ 5.5v ta= -40c~85c -10% 4 +9% mhz 2.2v~ 3.6v ta= -40c~85c -15% 8 +4% mhz 3.0v~ 5.5v ta= -40c~85c -8% 8 +9% mhz 3.0v~ 5.5v ta= -40c~85c -12% 12 +7% mhz f erc system clock (erc) 5v ta=25c, r=120kw * -2% 8 +2% mhz 5v ta=0~70c, r=120kw * -5% 8 +6% mhz 5v ta= -40c~85c, r=120kw * -7% 8 +9% mhz 3.0v~ 5.5v ta= -40c~85c, r=120kw * -9% 8 +10% mhz 2.2v~ 5.5v ta= -40c~85c, r=120kw * -15% 8 +10% mhz ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 15 february 9, 2011
symbol parameter test conditions min. typ. max. unit v dd conditions f lirc system clock (lirc) 5v ? -10% 32 +10% khz 2.2v~ 5.5v ta=-40c~+85c -50% 32 +60% khz f timer timer input pin frequency ? ? ? ? 1 f sys t res external reset low pulse width ? ? 1 ? ? m s t int interrupt pulse width ? ? 1 ? ? t sys t lvr low voltage width to reset ? ? 120 240 480 ms t lvd low voltage width to interrupt ? ? 20 45 90 ms t lvds lvdo stable time ? ? 15 ? ? m s t bgs vbg turn on stable time ? ? 200 ? ? m s t sst system start-up timer period (wake-up from halt) ? f sys =hxt ? 1024 ? t sys f sys =erc or hirc ? 15~16 ? f sys =lirc osc ? 1~2 ? note: 1. t sys =1/f sys 2. * for f erc , as the resistor tolerance will influence the frequency a precision resistor is recommended. 3. to maintain the accuracy of the internal hirc oscillator frequency, a 0.1 m f decoupling capacitor should be connected between vdd and vss and located as close to the device as possible. a/d converter characteristics ta=25 c symbol parameter test conditions min. typ. max. unit v dd conditions av dd a/d converter operating voltage ? ? 2.7 ? 5.5 v v adi a/d converter input voltage ? ? 0 ? vref v v ref a/d converter reference voltage ? ? 2 ? av dd v dnl differential non-linearity 5v t adck = 1.0ms ? 1 2 lsb inl integral non-linearity 5v t adck = 1.0ms ? 2 4 lsb i adc additional power consumption if a/d converter is used 3v no load, t adck = 0.5ms ? 0.90 1.35 ma 5v no load, t adck = 0.5ms ? 1.20 1.80 ma t adck a/d converter clock period ? ? 0.5 ? 10 ms t adc a/d conversion time (include sample and hold time) ? 12-bit a/d converter ? 16 ? t adck t ads a/d converter sampling time ? ? ? 4 ? t adck t on2st a/d converter on-to-start time ? ? 2 ? ? m s rev. 1.10 16 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
power-on reset characteristics ta=25 c symbol parameter test conditions min. typ. max. unit v dd conditions v por vdd start voltage to ensure power-on reset ? ? ? ? 100 mv rr vdd vdd raising rate to ensure power-on reset ? ? 0.035 ? ? v/ms t por minimum time for vdd stays at v por to ensure power-on reset ? ? 1 ? ? ms ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 17 february 9, 2011 t i m e v d d v p o r r r v d d t p o r
system architecture a key factor in the high-performance features of the holtek ra nge of microcontrollers is attributed to their internal system architecture. the range of devices take advantage of the usual features found within risc microcontrollers providing increased speed of operation and enhanced performance. the pipelining scheme is implemented in such a way that instruction fetching and instruction execution are overlapped, hence instructions are effectively executed in one cycle, with the exception of branch or call instructions. an 8-bit wide alu is used in practically all instruction set operations, which carries out arithmetic operations, logic operations, rotation, increment, decrement, branch decisions, etc. the internal data path is simplified by moving data through the accumulator and the alu. certain internal registers are implemented in the data memory and can be directly or indirectly addressed. the simple addressing methods of these registers along with additional architectural features ensure that a minimum of external components is required to provide a functional i/o and a/d control system with maximum reliability and flexibility. this makes the device suitable for low-cost, high-volume production for controller applications. clocking and pipelining the main system clock, derived from either a hxt, erc, hirc or l irc oscillator is subdivided into four internally generated non-overlapping clocks, t1~t4. the program counter is incremented at the beginning of the t1 clock during which time a new instruction is fetched. the remaining t2~t4 clocks carry out the decoding and execution functions. in this way, one t1~t4 clock cycle forms one instruction cycle. although the fetching and execution of instructions takes place in consecutive instruction cycles, the pipelining structure of the microcontroller ensures that instructions are effectively executed in one instruction cycle. the exception to this are instructions where the contents of the program counter are changed, such as subroutine calls or jumps, in which case the instruction will take one more instruction cycle to execute. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 18 february 9, 2011 f e t c h i n s t . ( p c ) e x e c u t e i n s t . ( p c - 1 ) f e t c h i n s t . ( p c + 1 ) e x e c u t e i n s t . ( p c ) f e t c h i n s t . ( p c + 2 ) e x e c u t e i n s t . ( p c + 1 ) p c p c + 1 p c + 2 f s y s ( s y s t e m c l o c k ) p h a s e c l o c k t 1 p r o g r a m c o u n t e r p h a s e c l o c k t 2 p h a s e c l o c k t 3 p h a s e c l o c k t 4 p i p e l i n i n g system clocking and pipelining f e t c h i n s t . 1 e x e c u t e i n s t . 1 f e t c h i n s t . 2 f l u s h p i p e l i n e 1 2 3 4 5 6 d e l a y : m o v a , [ 1 2 h ] c a l l d e l a y c p l [ 1 2 h ] : : n o p e x e c u t e i n s t . 2 f e t c h i n s t . 3 f e t c h i n s t . 6 e x e c u t e i n s t . 6 f e t c h i n s t . 7 instruction fetching
for instructions involving branches, such as jump or call instructions, two machine cycles are required to complete instruction execution. an extra cycle is required as the program takes one cycle to first obtain the actual jump or call address and then another cycle to actually execute the branch. the requirement for this extra cycle should be taken into account by programmers in timing sensitive applications. program counter during program execution, the program counter is used to keep track of the address of the next instruction to be executed. it is automatically incremented by one each time an instruction is executed except for instructions, such as 2 jmp 2 or 2 call 2 that demand a jump to a non-consecutive program memory address. only the lower 8 bits, known as the program counter low register, are directly addressable by the application program. when executing instructions requiring jumps to non-consecutive addresses such as a jump instruction, a subroutine call, interrupt or reset, etc., the microcontroller manages program control by loading the required address into the program counter. for conditional skip instructions, once the condition has been met, the next instruction, which has already been fetched during the present instruction execution, is discarded and a dummy cycle takes its place while the correct instruction is obtained. device program counter program counter high byte low byte (pcl register) ht66f13 pc9, pc8 pcl7~pcl0 ht66f14 pc10~pc8 HT66F15 pc11~pc8 program counter the lower byte of the program counter, known as the program cou nter low register or pcl, is available for program control and is a readable and writeable register. by transferring data directly into this register, a short program jump can be executed directly, however, as only this low byte is available for manipulation, the jumps are limited to the present page of memory, that is 256 locations. when such program jumps are executed it should also be noted that a dummy cycle will be inserted. manipulating the pcl register may cause program branching, so an extra cycle is needed to pre-fetch. stack this is a special part of the memory which is used to save the con tents of the program counter only. the stack has multiple levels depending upon the device and is neither part of the data nor part of the program space, and is neither readable nor writeable. the activated level is indexed by the stack pointer, and is neither readable nor writeable. at a subroutine call or interrupt acknowledge signal, the contents of the program counter are pushed onto the stack. at the end of a subroutine or an interrupt routine, signaled by a return instruction, ret or reti, the program counter is restored to its previous value from the stack. after a device reset, the stack pointer will point to the top of the stack. if the stack is full and an enabled interrupt takes place, the interrupt request flag will be recorded but the acknowledge signal will be inhibited. when the stack pointer is decremented, by ret or reti, the interrupt will be serviced. this feature prevents stack overflow allowing the programmer to use the structure more easily. however, when the stack is full, a call subroutine instruction can still be executed which will result in a stack overflow. precautions should be taken to avoid such cases which might cause unpredictable program branching. rev. 1.10 19 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
if the stack is overflow, the first program counter save in the stack will be lost. device stack levels ht66f13 4 ht66f14 4 HT66F15 8 arithmetic and logic unit - alu the arithmetic-logic unit or alu is a critical area of the m icrocontroller that carries out arithmetic and logic operations of the instruction set. connected to the main microcontroller data bus, the alu receives related instruction codes and performs the required arithmetic or logical operations after which the result will be placed in the specified register. as these alu calculation or operations may result in carry, borrow or other status changes, the status register will be correspondingly updated to reflect these changes. the alu supports the following functions: arithmetic operations: add, addm, adc, adcm, sub, subm, sbc, sbcm, daa logic operations: and, or, xor, , orm, xorm, cpl, cpla rotation rra, rr, rrca, rrc, rla, rl, rlca, rlc increment and decrement inca, inc, deca, dec branch decision, jmp, sz, sza, snz, siz, sdz, siza, sdza, call , ret, reti ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 20 february 9, 2011 p r o g r a m c o u n t e r s t a c k l e v e l 1 s t a c k l e v e l 2 s t a c k l e v e l 3 s t a c k l e v e l n p r o g r a m m e m o r y t o p o f s t a c k s t a c k p o i n t e r b o t t o m o f s t a c k
flash program memory the program memory is the location where the user code or progr am is stored. for this device series the program memory is flash type, which means it can be programmed and re-programmed a large number of times, allowing the user the convenience of code modification on the same device. by using the appropriate programming tools, these flash devices offer users the flexibility to conveniently debug and develop their applications while also offering a means of field programming and updating. structure the program memory has a capacity of 1k 1 4 bits to 4k 15 bits. the program memory is addressed by the program counter and also contains data, table information and interrupt entries. table data, which can be setup in any location within the program memory, is addressed by a separate table pointer register. device capacity ht66f20 1k14 ht66f30 2k15 ht66f40 4k15 special vectors within the program memory, certain locations are reserved fo r the reset and interrupts. the location 000h is reserved for use by the device reset for program initialisation. after a device reset is initiated, the program will jump to this location and begin execution. look-up table any location within the program memory can be defined as a look -up table where programmers can store fixed data. to use the look-up table, the table pointer must first be setup by placing the address of the look up data to be retrieved in the table pointer register, tblp and tbhp. these registers define the total address of the look-up table. after setting up the table pointer, the table data can be retrieved from the program memory using the 2 tabrd[m] 2 or 2 tabrdl[m] 2 instructions, respectively. when the instruction is executed, the lower order table byte from the program memory will be transferred to the user defined data memory register [m] as specified in the instruction. the higher order table data byte from the program memory will be transferred to the tblh special register. any unused bits in this transferred higher order byte will be read as 2 0 2 . rev. 1.10 21 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu i n t e r r u p t v e c t o r 0 0 0 4 h 0 3 f f h 1 4 b i t s 0 0 1 c h i n t e r r u p t v e c t o r 1 5 b i t s 0 7 f f h i n t e r r u p t v e c t o r 1 5 b i t s r e s e t 0 0 0 0 h h t 6 6 f 1 3 r e s e t h t 6 6 f 1 4 r e s e t h t 6 6 f 1 5 0 f f f h program memory structure
the accompanying diagram illustrates the addressing data flow of the look-up table. table program example the following example shows how the table pointer and table da ta is defined and retrieved from the microcontroller. this example uses raw table data located in the program memory which is stored there using the org statement. the value at this org statement is 2 700h 2 which refers to the start address of the last page within the 2k program memory of the ht66f14. the table pointer is setup here to have an initial value of 2 06h 2 . this will ensure that the first data read from the data table will be at the program memory address 2 706h 2 or 6 locations after the start of the last page. note that the value for the table pointer is referenced to the first address of the present page if the 2 tabrd [m] 2 instruction is being used. the high byte of the table data which in this case is equal to zero will be transferred to the tblh register automatically when the 2 tabrd [m] 2 instruction is executed. because the tblh register is a read-only register and cannot be restored, care should be taken to ensure its protection if both the main routine and interrupt service routine use table read instructions. if using the table read instructions, the interrupt service routines may change the value of the tblh and subsequently cause errors if used again by the main routine. as a rule it is recommended that simultaneous use of the table read instructions should be avoided. however, in situations where simultaneous use cannot be avoided, the interrupts should be disabled prior to the execution of any main routine table-read instructions. note that all table related instructions require two instruction cycles to complete their operation. table read program example t empreg1 db ? ; temporary register #1 tempreg2 db ? ; temporary register #2 : : mov a,06h ; initialise low table pointer - note that this address mov tblp,a ; is referenced mov a,07h ; initialise high table pointer mov tbhp,a : : tabrd tempreg1 ; transfers value in table referenced by table pointer data at ; program memory address 2 706h 2 transferred to tempreg1 and tblh dec tblp ; reduce value of table pointer by one tabrd tempreg2 ; transfers value in table referenced by table pointer data at ; program memory address 2 705h 2 transferred to tempreg2 and tblh ; in this example the data 2 1ah 2 is transferred to tempreg1 and ; data 2 0fh 2 to register tempreg2 : : org 700h ; sets initial address of program memory dc 00ah, 00bh, 00ch, 00dh, 00eh, 00fh, 01ah, 01bh : : ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 22 february 9, 2011 r e g i s t e r t b l h u s e r s e l e c t e d r e g i s t e r h i g h b y t e l o w b y t e t b l p r e g i s t e r d a t a a d d r e s s 1 4 ~ 1 5 b i t s p r o g r a m m e m o r y l a s t p a g e o r t b h p r e g i s t e r
in circuit programming the provision of flash type program memory provides the user w ith a means of convenient and easy upgrades and modifications to their programs on the same device. as an additional convenience, holtek has provided a means of programming the microcontroller in-circuit using a 5-pin interface. this provides manufacturers with the possibility of manufacturing their circuit boards complete with a programmed or un-programmed microcontroller, and then programming or upgrading the program at a later stage. this enables product manufacturers to easily keep their manufactured products supplied with the latest program releases without removal and re-insertion of the device. the holtek flash mcu to writer programming pin correspondence table is as follows: holtek writer ht66f13/14/15 pin description pin name pin name sdata pa0 serial address and data -- read/write sclk pa2 address and data serial clock input vpp res reset input vdd vdd power supply (5.0v) vss vss ground the program memory can be programmed serially in-circuit using this 5-wire interface. data is downloaded and uploaded serially on a single pin with an additional line for the clock. two addi - tional lines are required for the power supply and one line for the reset. the technical details regard - ing the in-circuit programming of the devices are beyond the scope of this document and will be supplied in supplementary literature. during the programming process the res pin will be held low by the programmer disabling the normal operation of the microcontroller and taking control of the pa0 and pa2 i/o pins for data and clock programming purposes. the user must there take care to ensure that no other outputs are connected to these two pins. rev. 1.10 23 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu * * * v d d v p p s d a t a s c l k v s s t o o t h e r c i r c u i t p a 0 p a 2 v s s r e s v d d w r i t e r c o n n e c t o r s i g n a l s m c u p r o g r a m m i n g p i n s note: * may be resistor or capacitor. the resistance of * must be greater than 1k w or the capacitance of * must be less than 1nf.
ram data memory the data memory is a volatile area of 8-bit wide ram internal me mory and is the location where temporary information is stored. structure divided into two sections, the first of these is an area of ram, known as the special function data memory. here are located registers which are necessary for correct operation of the device. many of these registers can be read from and written to directly under program control, however, some remain protected from user manipulation. the second area of data memory is known as the general purpose data memory, which is reserved for general purpose use. all locations within this area are read and write accessible under program control. device capacity address ht66f13 648 40h~7fh ht66f14 968 40h~9fh HT66F15 1928 40h~ffh general purpose data memory structure ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 24 february 9, 2011
rev. 1.10 25 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu h t 6 6 f 1 3 h t 6 6 f 1 4 0 0 h 0 1 h 0 2 h 0 3 h 0 4 h 0 5 h 0 6 h 0 7 h 0 8 h 0 9 h 0 a h 0 b h 0 c h 0 d h 0 e h 0 f h 1 0 h 1 1 h 1 2 h 1 3 h 1 4 h 1 5 h 1 6 h 1 7 h 1 8 h 1 9 h 1 a h 1 b h 1 c h 1 d h 1 e h 1 f h 2 0 h 2 1 h 2 2 h 2 3 h 2 4 h 2 5 h 2 6 h 2 7 h 2 8 h 2 9 h 2 a h 2 b h 2 c h 2 d h 2 e h 2 f h 3 0 h 3 1 h 3 2 h 3 3 h 3 4 h 3 5 h 3 6 h 3 7 h 3 8 h 3 9 h 3 a h 3 b h 3 c h 3 d h 3 e h 3 f h i a r 0 m p 0 i a r 1 m p 1 u n u s e d a c c p c l t b l p t b l h t b h p s t a t u s s m o d l v d c i n t e g w d t c t b c i n t c 0 i n t c 1 u n u s e d u n u s e d u n u s e d u n u s e d u n u s e d u n u s e d p a w u p a p u p a p a c p b p u p b p b c p c p u p c p c c u n u s e d u n u s e d u n u s e d u n u s e d u n u s e d u n u s e d a d r l a d r h a d c r 0 a d c r 1 a c e r t m p c u n u s e d u n u s e d u n u s e d u n u s e d u n u s e d u n u s e d t m 1 c 0 t m 1 c 1 u n u s e d t m 1 d l t m 1 d h t m 1 a l t m 1 a h u n u s e d u n u s e d s c o m c u n u s e d u n u s e d 0 0 h 0 1 h 0 2 h 0 3 h 0 4 h 0 5 h 0 6 h 0 7 h 0 8 h 0 9 h 0 a h 0 b h 0 c h 0 d h 0 e h 0 f h 1 0 h 1 1 h 1 2 h 1 3 h 1 4 h 1 5 h 1 6 h 1 7 h 1 8 h 1 9 h 1 a h 1 b h 1 c h 1 d h 1 e h 1 f h 2 0 h 2 1 h 2 2 h 2 3 h 2 4 h 2 5 h 2 6 h 2 7 h 2 8 h 2 9 h 2 a h 2 b h 2 c h 2 d h 2 e h 2 f h 3 0 h 3 1 h 3 2 h 3 3 h 3 4 h 3 5 h 3 6 h 3 7 h 3 8 h 3 9 h 3 a h 3 b h 3 c h 3 d h 3 e h 3 f h i a r 0 m p 0 i a r 1 m p 1 u n u s e d a c c p c l t b l p t b l h t b h p s t a t u s s m o d l v d c i n t e g w d t c t b c i n t c 0 i n t c 1 u n u s e d u n u s e d m f i 0 m f i 1 u n u s e d u n u s e d p a w u p a p u p a p a c p b p u p b p b c p c p u p c p c c p d p u p d p d c u n u s e d u n u s e d u n u s e d a d r l a d r h a d c r 0 a d c r 1 a c e r t m p c t m 0 c 0 t m 0 c 1 t m 0 d l t m 0 d h t m 0 a l a m 0 a h t m 1 c 0 t m 1 c 1 u n u s e d t m 1 d l t m 1 d h t m 1 a l t m 1 a h u n u s e d u n u s e d s c o m c u n u s e d u n u s e d h t 6 6 f 1 5 0 0 h 0 1 h 0 2 h 0 3 h 0 4 h 0 5 h 0 6 h 0 7 h 0 8 h 0 9 h 0 a h 0 b h 0 c h 0 d h 0 e h 0 f h 1 0 h 1 1 h 1 2 h 1 3 h 1 4 h 1 5 h 1 6 h 1 7 h 1 8 h 1 9 h 1 a h 1 b h 1 c h 1 d h 1 e h 1 f h 2 0 h 2 1 h 2 2 h 2 3 h 2 4 h 2 5 h 2 6 h 2 7 h 2 8 h 2 9 h 2 a h 2 b h 2 c h 2 d h 2 e h 2 f h 3 0 h 3 1 h 3 2 h 3 3 h 3 4 h 3 5 h 3 6 h 3 7 h 3 8 h 3 9 h 3 a h 3 b h 3 c h 3 d h 3 e h 3 f h i a r 0 m p 0 i a r 1 m p 1 u n u s e d a c c p c l t b l p t b l h t b h p s t a t u s s m o d l v d c i n t e g w d t c t b c i n t c 0 i n t c 1 u n u s e d u n u s e d m f i 0 m f i 1 u n u s e d u n u s e d p a w u p a p u p a p a c p b p u p b p b c p c p u p c p c c p d p u p d p d c u n u s e d u n u s e d u n u s e d a d r l a d r h a d c r 0 a d c r 1 a c e r t m p c t m 0 c 0 t m 0 c 1 t m 0 d l t m 0 d h t m 0 a l t m 0 a h t m 1 c 0 t m 1 c 1 t m 1 c 2 t m 1 d l t m 1 d h t m 1 a l t m 1 a h t m 1 b l t m 1 b h s c o m c u n u s e d u n u s e d special purpose data memory structure
special function register description most of the special function register details will be describ ed in the relevant functional section. however, several registers require a separate description in this section. indirect addressing registers - iar0, iar1 the indirect addressing registers, iar0 and iar1, although h aving their locations in normal ram register space, do not actually physically exist as normal registers. the method of indirect addressing for ram data manipulation uses these indirect addressing registers and memory pointers, in contrast to direct memory addressing, where the actual memory address is specified. actions on the iar0 and iar1 registers will result in no actual read or write operation to these registers but rather to the memory location specified by their corresponding memory pointers, mp0 or mp1. as the indirect addressing registers are not physically implemented, reading the indirect addressing registers indirectly will return a result of 00h and writing to the registers indirectly will result in no operation. indirect addressing program example d ata .section data adres1 db ? adres2 db ? adres3 db ? adres4 db ? block db ? code .section at 0 code org 00h start: mov a,04h ; setup size of block mov block,a mov a,offset adres1 ; accumulator loaded with first ram address mov mp0,a ; setup memory pointer with first ram address loop: clr iar0 ; clear the data at address defined by mp0 inc mp0 ; increment memory pointer sdz block ; check if last memory location has been cleared jm p loop continue: the important point to note here is that in the example shown above, no reference is made to specific ram addresses. memory pointers - mp0, mp1 two memory pointers, known as mp0 and mp1 are provided. these m emory pointers are physically implemented in the data memory and can be manipulated in the same way as normal registers providing a convenient way with which to address and track data. when any operation to the relevant indirect addressing registers is carried out, the actual address that the microcontroller is directed to is the address specified by the related memory pointer. note that for the ht66f13 device, bit 7 of the memory pointers is not required to address the full memory space. when bit 7 of the memory pointers for ht66f13 device is read, a value of 1 will be returned. the following example shows how to clear a section of four data memory locations already defined as locations adres1 to adres4. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 26 february 9, 2011
accumulator - acc the accumulator is central to the operation of any microcontr oller and is closely related with operations carried out by the alu. the accumulator is the place where all intermediate results from the alu are stored. without the accumulator it would be necessary to write the result of each calculation or logical operation such as addition, subtraction, shift, etc., to the data memory resulting in higher programming and timing overheads. data transfer operations usually involve the temporary storage function of the accumulator; for example, when transferring data between one user defined register and another, it is necessary to do this by passing the data through the accumulator as no direct transfer between two registers is permitted. program counter low register - pcl to provide additional program control functions, the low byt e of the program counter is made accessible to programmers by locating it within the special purpose area of the data memory. by manipulating this register, direct jumps to other program locations are easily implemented. loading a value directly into this pcl register will cause a jump to the specified program memory location. however, as the register is only 8-bit wide, only jumps within the current program memory page are permitted. when such operations are used, note that a dummy cycle will be inserted. look-up table registers - tblp, tbhp, tblh these three special function registers are used to control op eration of the look-up table which is stored in the program memory. tblp and tbhp are the table pointer and indicates the location where the table data is located. their value must be setup before any table read commands are executed. their value can be changed, for example using the 2 inc 2 or 2 dec 2 instructions, allowing for easy table data pointing and reading. tblh is the location where the high order byte of the table data is stored after a table read data instruction has been executed. note that the lower order table data byte is transferred to a user defined location. status register - status this 8-bit register contains the zero flag (z), carry flag (c) , auxiliary carry flag (ac), overflow flag (ov), power down flag (pdf), and watchdog time-out flag (to). these arithmetic/logical operation and system management flags are used to record the status and operation of the microcontroller. with the exception of the to and pdf flags, bits in the status register can be altered by instructions like most other registers. any data written into the status register will not change the to or pdf flag. in addition, operations related to the status register may give different results due to the different instruction operations. the to flag can be affected only by a system power-up, a wdt time-out or by executing the 2 clr wdt 2 or 2 halt 2 instruction. the pdf flag is affected only by executing the 2 halt 2 or 2 clr wdt 2 instruction or during a system power-up. the z, ov, ac and c flags generally reflect the status of the latest operations. c i s set if an operation results in a carry during an addition operation or if a borrow does not take place during a subtraction operation; otherwise c is cleared. c is also affected by a rotate through carry instruction. ac i s set if an operation results in a carry out of the low nibbles in addition, or no borrow from the high nibble into the low nibble in subtraction; otherwise ac is cleared. z i s set if the result of an arithmetic or logical operation is zero; otherwise z is cleared. ov i s set if an operation results in a carry into the highest-order bit but not a carry out of the highest-order bit, or vice versa; otherwise ov is cleared. rev. 1.10 27 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
pdf i s cleared by a system power-up or executing the 2 clr wdt 2 instruction. pdf is set by executing the 2 halt 2 instruction. to i s cleared by a system power-up or executing the 2 clr wdt 2 or 2 halt 2 instruction. to is set by a wdt time-out. in addition, on entering an interrupt sequence or executing a subroutine call, the status register will not be pushed onto the stack automatically. if the contents of the status registers are important and if the subroutine can corrupt the status register, precautions must be taken to correctly save it. status register bit 7 6 5 4 3 2 1 0 name ? ? to pdf ov z ac c r/w ? ? r r r/w r/w r/w r/w por ? ? 0 0 x x x x 2x2 unknown bit 7, 6 unimplemented, read as 202 bit 5 to : watchdog time-out flag 0: after power up or executing the 2 clr wdt2 or 2 halt2 instruction 1: a watchdog time-out occurred. bit 4 pdf: power down flag 0: after power up or executing the 2 clr wdt2 instruction 1: by executing the 2 halt2 instruction bit 3 ov : overflow flag 0: no overflow 1: an operation results in a carry into the highest-order bit but not a carry out of the highest-order bit or vice versa. bit 2 z: zero flag 0: the result of an arithmetic or logical operation is not zero 1: the result of an arithmetic or logical operation is zero bit 1 ac: auxiliary flag 0: no auxiliary carry 1: an operation results in a carry out of the low nibbles in addition, or no borrow from the high nibble into the low nibble in subtraction bit 0 c: carry flag 0: no carry-out 1: an operation results in a carry during an addition operation or if a borrow does not take place during a subtraction operation c is also affected by a rotate through carry instruction. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 28 february 9, 2011
oscillator various oscillator options offer the user a wide range of func tions according to their various application requirements. the flexible features of the oscillator functions ensure that the best optimisation can be achieved in terms of speed and power saving. oscillator selections and operation are selected through a combination of configuration options and registers. oscillator overview in addition to being the source of the main system clock the osc illators also provide clock sources for the watchdog timer and time base interrupts. external oscillators requiring some external components as well as fully integrated internal oscillators, requiring no external components, are provided to form a wide range of both fast and slow system oscillators. all oscillator options are selected through the configuration options. the higher frequency oscillators provide higher performance but carry with it the disadvantage of higher power requirements, while the opposite is of course true for the lower frequency oscillators. with the capability of dynamically switching between fast and slow system clock, the device has the flexibility to optimize the performance/ power ratio, a feature especially important in power sensitive portable applications. type name freq. pins external crystal hxt 400khz~20mhz osc1/osc2 external rc erc 8mhz osc1 internal high speed rc hirc 4, 8 or 12mhz ? internal low speed rc lirc 32khz ? oscillator types system clock configurations there are four system oscillators, three high speed oscillat ors and one low speed oscillator. the high speed oscillators are the external crystal/ceramic oscillator - hxt, the external - erc, and the internal rc oscillator - hirc. the low speed oscillator is the internal 32 khz oscillator - lirc. selecting whether the low or high speed oscillator is used as the system oscillator is implemented using the hlclk bit and cks2~cks0 bits in the smod register and as the system clock can be dynamically selected. rev. 1.10 29 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu hxt high speed oscillator erc hirc lirc low speed oscillator f h 6-stage prescaler high speed oscillator configuration option hlclk, cks2~cks0 bits f h /2 f h /4 f h /8 f h /16 f h /32 f h /64 f lirc f l f sub fast wake-up from sleep mode or idle mode control (for hxt only) f sys system clock configurations
the actual source clock used for each of the high speed and low speed oscillators is chosen via configuration options. the frequency of the slow speed or high speed system clock is also determined using the hlclk bit and cks2~cks0 bits in the smod register. note that two oscillator selections must be made namely one high speed and one low speed system oscillators. it is not possible to choose a no-oscillator selection for either the high or low speed oscillator. external crystal/ ceramic oscillator - hxt the external crystal/ceramic system oscillator is one of the high frequency oscillator choices, which is selected via configuration option. for most crystal oscillator configurations, the simple connection of a crystal across osc1 and osc2 will create the necessary phase shift and feedback for oscillation, without requiring external capacitors. however, for some crystal types and frequencies, to ensure oscillation, it may be necessary to add two small value capacitors, c1 and c2. using a ceramic resonator will usually require two small value capacitors, c1 and c2, to be connected as shown for oscillation to occur. the values of c1 and c2 should be selected in consultation with the crystal or resonator manufacturer s specification. crystal oscillator c1 and c2 values crystal frequency c1 c2 12mhz 0pf 0pf 8mhz 0pf 0pf 4mhz 0pf 0pf 1mhz 100pf 100pf note: c1 and c2 values are for guidance only. crystal recommended capacitor values ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 30 february 9, 2011 o s c 1 o s c 2 r f t o i n t e r n a l c i r c u i t s i n t e r n a l o s c i l l a t o r c i r c u i t c 1 c 2 r p n o t e : 1 . r p i s n o r m a l l y n o t r e q u i r e d . c 1 a n d c 2 a r e r e q u i r e d . 2 . a l t h o u g h n o t s h o w n o s c 1 / o s c 2 p i n s h a v e a p a r a s i t i c c a p a c i t a n c e o f a r o u n d 7 p f . crystal/resonator oscillator - hxt
external rc oscillator - erc using the erc oscillator only requires that a resistor, with a value between 24k w and 2.4m w , is connected between osc1 and v dd , and a capacitor is connected between osc1 and ground, provid ing a low cost oscillator configuration. it is only the external resistor that determines the oscillation frequency; the external capacitor has no influence over the frequency and is connected for stability purposes only. device trimming during the manufacturing process and the inclusion of internal frequency compensation circuits are used to ensure that the influence of the power supply voltage, temperature and process variations on the oscillation frequency are minimised. as a resistance/ frequency reference point, it can be noted that with an external 120k w resistor connected and with a 5v voltage power supply and temperature of 25 c degrees, the oscillator will have a frequency of 8mhz within a tolerance of 2%. here only the osc1 pin is used, which is shared with i/o pin pb1, leaving pin pb2 free for use as a normal i/o pin. internal rc oscillator - hirc the internal rc oscillator is a fully integrated system oscil lator requiring no external components. the internal rc oscillator has three fixed frequencies of either 4mhz, 8mhz or 12mhz. device trimming during the manufacturing process and the inclusion of internal frequency compensation circuits are used to ensure that the influence of the power supply voltage, temperature and process variations on the oscillation frequency are minimised. as a result, at a power supply of either 3v or 5v and at a temperature of 25 c degrees, the fixed oscillation frequency of 4mhz, 8mhz or 12mhz will have a tolerance within 2%. note that if this internal system clock option is selected, as it requires no external pins for its operation, i/o pins pb1 and pb2 are free for use as normal i/o pins. internal 32khz oscillator - lirc the internal 32khz system oscillator is one of the low frequen cy oscillator choices, which is selected via configuration option. it is a fully integrated rc oscillator with a typical frequency of 32khz at 5v, requiring no external components for its implementation. device trimming during the manufacturing process and the inclusion of internal frequency compensation circuits are used to ensure that the influence of the power supply voltage, temperature and process variations on the oscillation frequency are minimised. as a result, at a power supply of 5v and at a temperature of 25j degrees, the fixed oscillation frequency of 32khz will have a tolerance within 10%. supplementary oscillator the low speed oscillator, in addition to providing a system cl ock source, is also used to provide a clock source to two other device functions. these are the watchdog timer and the time base interrupts. rev. 1.10 31 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu o s c 1 2 0 p f v d d r o s c p b 2 external rc oscillator - erc
operating modes and system clocks present day applications require that their microcontrolle rs have high performance but often still demand that they consume as little power as possible, conflicting requirements that are especially true in battery powered portable applications. the fast clocks required for high performance will by their nature increase current consumption and of course vice versa, lower speed clocks reduce current consumption. as holtek has provided these devices with both high and low speed clock sources and the means to switch between them dynamically, the user can optimise the operation of their microcontroller to achieve the best performance/power ratio. system clocks the device has many different clock sources for both the cpu an d peripheral function operation. by providing the user with a wide range of clock options using configuration options and register programming, a clock system can be configured to obtain maximum application performance. the main system clock can come from a high frequency f h or low frequency f l source and is selected u sing the hlclk bit and cks2~cks0 bits in the smod register. the high speed system clock can be sourced from either a hxt, erc or hirc oscillator, selected via a configuration option. the low speed system clock source can be sourced from internal clock f l . if f l is selected, then it can be sourced b y the lirc oscillator. the other choice, which is a divided version of the high speed system oscillator has a range of f h /2~f h /64. note that when the system clock source f sys is switched to f l from f h , the high s peed oscillation will stop to conserve the power. thus there is no f h ~f h /64 for peripheral circuit to use. t here are two additional internal clocks for the peripheral circuits, the substitute clock, f sub , and the t ime base clock, f tbc . these internal clocks are sourced by the lirc oscillator. th e f sub clock is used t o provide a substitute clock for the microcontroller just after a wake-up has occurred to enable faster wake-up times. together with f sys /4 it is also used as one of the clock sources for the watchdog ti mer. the f tbc clock is used as a source for the time base interrupt functions and for the tms. system operation modes there are six different modes of operation for the microcontr oller, each one with its own special characteristics and which can be chosen according to the specific performance and power requirements of the application. there are two modes allowing normal operation of the microcontroller, the normal mode and slow mode. the remaining four modes, the sleep0, sleep1, idle0 and idle1 mode are used when the microcontroller cpu is switched off to conserve power. operation mode description cpu f sys f sub f s f tbc normal mode on f h ~ f h /64 on on on slow mode on f l on on on idle0 mode on off on on/off on idle1 mode off on on on on sleep0 mode off off off off off sleep1 mode off off on on off ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 32 february 9, 2011
normal mode as the name suggests this is one of the main operating modes whe re the microcontroller has all of its functions operational and where the system clock is provided by one of the high speed oscillators. this mode operates allowing the microcontroller to operate normally with a clock source will come from one of the high speed oscillators, either the hxt, erc or hirc oscillators. the high speed oscillator will however first be divided by a ratio ranging from 1 to 64, the actual ratio being selected by the cks2~cks0 and hlclk bits in the smod register. although a high speed oscillator is used, running the microcontroller at a divided clock ratio reduces the operating current. slow mode this is also a mode where the microcontroller operates normal ly although now with a slower speed clock source. the clock source used will be from the low speed oscillator lirc. running the microcontroller in this mode allows it to run with much lower operating currents. in the slow mode, the f h is off. sleep0 mode the sleep mode is entered when an halt instruction is executed and when the idlen bit in the smod register is low. in the sleep0 mode the cpu will be stopped, and the f sub and f s clocks will be s topped too, and the watchdog timer function is disabled. in this mode, the lvden is must set to 2 0 2 . if the lvden is set to 2 1 2 , it won t enter the sleep0 mode. sleep1 mode the sleep mode is entered when a halt instruction is executed a nd the idlen bit in the smod register is low. in the sleep1 mode the cpu will be stopped. however, the f sub and f s clocks will c ontinue to operate if the lvden is set to 2 1 2 or the watchdog timer function is enabled and if its clock source is chosen via configuration option to come from the f sub . idle0 mode the idle0 mode is entered when a halt instruction is executed a nd when the idlen bit in the smod register is high and the fsyson bit in the wdtc register is low. in the idle0 mode the system oscillator will be inhibited from driving the cpu but some peripheral functions will remain operational such as the watchdog timer and tms. in the idle0 mode, the system oscillator will be stopped. in the idle0 mode the watchdog timer clock, f s , will either be on or off depending upon the f s clock source. if the source is f sys /4, then the f s clock will be off, and if the source comes from f sub then f s will be on. idle1 mode the idle1 mode is entered when a halt instruction is executed a nd when the idlen bit in the smod register is high and the fsyson bit in the wdtc register is high. in the idle1 mode the system oscillator will be inhibited from driving the cpu but may continue to provide a clock source to keep some peripheral functions operational such as the watchdog timer and tms. in the idle1 mode, the system oscillator will continue to run, and this system oscillator may be high speed or low speed system oscillator. in the idle1 mode the watchdog timer clock, f s , will be on. if the source is f sys /4, then the f s clock will be on, and if the source comes from f sub then f s will be on. rev. 1.10 33 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
control register a single register, smod, is used for overall control of the int ernal clocks within the device. smod register bit 7 6 5 4 3 2 1 0 name cks2 cks1 cks0 fsten lto hto idlen hlclk r/w r/w r/w r/w r/w r r r/w r/w por 0 0 0 0 0 0 1 1 bit 7~5 cks2~cks0 : the system clock selection when hlclk is 202 000: f l (f lirc ) 001: f l (f lirc ) 010: f h /64 011: f h /32 100: f h /16 101: f h /8 110: f h /4 111: f h /2 these three bits are used to select which clock is used as the system clock source. in addition to the system clock source, which is the lirc, a divided version of the high speed system oscillator can also be chosen as the system clock source. bit 4 fsten : fast wake-up control (only for hxt) 0: disable 1: enable this is the fast wake-up control bit which determines if the f sub clock source is initially used after the device wakes up. when the bit is high, the f sub clock source can be used as a temporary system clock to provide a faster wake up time as the f sub clock is available. bit 3 lto : low speed system oscillator ready flag 0: not ready 1: ready this is the low speed system oscillator ready flag which indicates when the low speed system oscillator is stable after power on reset or a wake-up has occurred. the flag will be low when in the sleep0 mode but after a wake-up has occurred, the flag will change to a high level after 1~2 clock cycles as the lirc oscillator is used. bit 2 hto : high speed system oscillator ready flag 0: not ready 1: ready this is the high speed system oscillator ready flag which indicates when the high speed system oscillator is stable. this flag is cleared to 202 by hardware when the device is powered on and then changes to a high level after the high speed system oscillator is stable. therefore this flag will always be read as 212 by the application program after device power-on. the flag will be low when in the sleep or idle0 mode but after a wake-up has occurred, the flag will change to a high level after 1024 clock cycles if the hxt oscillator is used and after 15~16 clock cycles if the erc or hirc oscillator is used. bit 1 idlen: idle mode control 0: disable 1: enable this is the idle mode control bit and determines what happens when the halt instruction is executed. if this bit is high, when a halt instruction is executed the device will enter the idle mode. in the idle1 mode the cpu will stop running but the system clock will continue to keep the peripheral functions operational as the fsyson bit is high. if fsyson bit is low, the cpu and the system clock will all stop in idle0 mode. if the bit is low the device will enter the sleep mode when a halt instruction is executed. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 34 february 9, 2011
bit 0 hlclk: system clock selection 0: f h /2 ~ f h /64 or f l 1: f h this bit is used to select if the f h clock or the f h /2 ~ f h /64 or fl clock is used as the system clock. when the bit is high the f h clock will be selected and if low the f h /2 ~ f h /64 or f l clock will be selected. when system clock switches from the f h clock to the f l clock, the f h clock will be automatically switched off to conserve power. fast wake-up to minimise power consumption the device can enter the sleep o r idle0 mode, where the system clock source to the device will be stopped. however when the device is woken up again, it can take a considerable time for the original system oscillator to restart, stabilise and allow normal operation to resume. to ensure the device is up and running as fast as possible a fast wake-up function is provided, which allows f sub , namely the lirc oscillator, to act as a temporary clock to fir st drive the system until the original system oscillator has stabilised. as the clock source for the fast wake-up function is f sub , t he fast wake-up function is only available in the sleep1 and idle0 modes. when the device is woken up from the sleep0 mode, the fast wake-up function has no effect because the f sub clock is s topped. the fast wake-up enable/disable function is controlled using the fsten bit in the smod register. if the hxt oscillator is selected as the normal mode system clock and the fast wake-up function is enabled, then it will take one to two t sub clock cycles of the lirc oscillator for the system to wake-up. t he system will then initially run under the f sub clock source until 1024 hxt clock cycles have e lapsed, at which point the hto flag will switch high and the system will switch over to operating from the hxt oscillator. if the erc or hirc oscillators or lirc oscillator is used as the system oscillator then it will take 15~16 clock cycles of the erc or hirc or 1~2 cycles of the lirc to wake up the system from the sleep or idle0 mode. the fast wake-up bit, fsten will have no effect in these cases. system oscillator fsten bit wake-up time (sleep0 mode) wake-up time (sleep1 mode) wake-up time (idle0 mode) wake-up time (idle1 mode) hxt 0 1024 hxt cycles 1024 hxt cycles 1~2 hxt cycles 1 1024 hxt cycles 1~2 f sub cycles (system runs with f sub first for 1024 hxt cycles and then switches over to run with the hxt clock) 1~2 hxt cycles erc x 15~16 erc cycles 15~16 erc cycles 1~2 erc cycles hirc x 15~16 hirc cycles 15~16 hirc cycles 1~2 hirc cycles lirc x 1~2 lirc cycles 1~2 lirc cycles 1~2 lirc cycles 2x2 : dont care wake-up times note that if the watchdog timer is disabled, which means that the lirc oscillator is off, then there will be no fast wake-up function available when the device wakes-up from the sleep0 mode. rev. 1.10 35 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
operating mode switching the device can switch between operating modes dynamically al lowing the user to select the best performance/power ratio for the present task in hand. in this way microcontroller operations that do not require high performance can be executed using slower clocks thus requiring less operating current and prolonging battery life in portable applications. in simple terms, mode switching between the normal mode and slow mode is executed using the hlclk bit and cks2~cks0 bits in the smod register while mode switching from the normal/slow modes to the sleep/idle modes is executed via the halt instruction. when a halt instruction is executed, whether the device enters the idle mode or the sleep mode is determined by the condition of the idlen bit in the smod register and fsyson in the wdtc register. when the hlclk bit switches to a low level, which implies that clock source is switched from the high speed clock source, f h , to the clock source, f h /2~f h /64 or f l . if the clock is from the f l , the high s peed clock source will stop running to conserve power. when this happens it must be noted that the f h /16 and f h /64 internal clock sources will also stop running, which may a ffect the operation of other internal functions such as the tms. the accompanying flowchart shows what happens when the device moves between the various operating modes. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 36 february 9, 2011 s l e e p 0 h a l t i n s t r u c t i o n i s e x e c u t e d f s y s o f f c p u s t o p i d l e n = 0 f t b c o f f f s u b o f f w d t & l v d o f f n o r m a l f s y s = f h ~ f h / 6 4 f h o n c p u r u n f s y s o n f t b c o n f s u b o n i d l e 1 h a l t i n s t r u c t i o n i s e x e c u t e d c p u s t o p i d l e n = 1 f s y s o n = 1 f s y s o n f t b c o n f s u b o n i d l e 0 h a l t i n s t r u c t i o n i s e x e c u t e d c p u s t o p i d l e n = 1 f s y s o n = 0 f s y s o f f f t b c o n f s u b o n s l o w f s y s = f l f l o n c p u r u n f s y s o n f t b c o n f s u b o n f h o f f s l e e p 1 h a l t i n s t r u c t i o n i s e x e c u t e d f s y s o f f c p u s t o p i d l e n = 0 f t b c o f f f s u b o n w d t o r l v d o n
normal mode to slow mode switching when running in the normal mode, which uses the high speed syst em oscillator, and therefore consumes more power, the system clock can switch to run in the slow mode by set the hlclk bit to 0 and set the cks2~cks0 bits to 2 000b 2 or 2 001b 2 in the smod register. this will then use the low speed system oscillator which will consume less power. users may decide to do this for certain operations which do not require high performance and can subsequently reduce power consumption. the slow mode is sourced from the lirc oscillator and therefore requires these oscillators to be stable before full mode switching occurs. this is monitored using the lto bit in the smod register. rev. 1.10 37 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu s l o w m o d e s l e e p 0 m o d e s l e e p 1 m o d e i d e l 0 m o d e i d l e 1 m o d e n o r m a l m o d e c k s 2 ~ c k s 0 = 0 0 x b & h l c l k = 0 w d t a n d l v d a r e a l l o f f i d l e n = 0 h a l t i n s t r u c t i o n i s e x e c u t e d w d t o r l v d i s o n i d l e n = 0 h a l t i n s t r u c t i o n i s e x e c u t e d i d l e n = 1 , f s y s o n = 0 h a l t i n s t r u c t i o n i s e x e c u t e d i d l e n = 1 , f s y s o n = 1 h a l t i n s t r u c t i o n i s e x e c u t e d
slow mode to normal mode switching in slow mode the system uses the lirc low speed system oscillat or. to switch back to the normal mode, where the high speed system oscillator is used, the hlclk bit should be set to 2 1 2 or hlclk bit is 2 0 2 but cks2~cks0 is set to 010b, 011b, 100b, 101b, 110b or 111b. as a certain amount of time will be required for the high frequency clock to stabilise, the status of the hto bit is checked. the amount of time required for high speed system oscillator stabilization depends upon which high speed system oscillator type is used. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 38 february 9, 2011 s l o w m o d e s l e e p 0 m o d e s l e e p 1 m o d e i d e l 0 m o d e i d l e 1 m o d e n o r m a l m o d e c k s 2 ~ c k s 0 = 0 0 x b & h l c l k = 0 w d t a n d l v d a r e a l l o f f i d l e n = 0 h a l t i n s t r u c t i o n i s e x e c u t e d w d t o r l v d i s o n i d l e n = 0 h a l t i n s t r u c t i o n i s e x e c u t e d i d l e n = 1 , f s y s o n = 0 h a l t i n s t r u c t i o n i s e x e c u t e d i d l e n = 1 , f s y s o n = 1 h a l t i n s t r u c t i o n i s e x e c u t e d
entering the sleep0 mode there is only one way for the device to enter the sleep0 mode and that is to execute the halt instruction in the application program with the idlen bit in smod register equal to 0 and the wdt and lvd both off. when this instruction is executed under the conditions described above, the following will occur: the system clock, wdt clock and time base clock will be stopped and the application program will stop at the 2 halt 2 instruction. the data memory contents and registers will maintain their pr esent condition. the wdt will be cleared and stopped no matter if the wdt clock so urce originates from the f sub clock or from the system clock. the i/o ports will maintain their present conditions. in the status register, the power down flag, pdf, will be set an d the watchdog time-out flag, to, will be cleared. entering the sleep1 mode there is only one way for the device to enter the sleep1 mode and that is to execute the 2 halt 2 instruction in the application program with the idlen bit in smod register equal to 2 0 2 and the wdt or lvd on. when this instruction is executed under the conditions described above, the following will occur: the system clock and time base clock will be stopped and the app lication program will stop at the 2 halt 2 instruction, but the wdt or lvd will remain with the clock source coming from the f sub clock. the data memory contents and registers will maintain their pr esent condition. the wdt will be cleared and resume counting if the wdt clock sou rce is selected to come from the f sub clock as the wdt is enabled. the i/o ports will maintain their present conditions. in the status register, the power down flag, pdf, will be set an d the watchdog time-out flag, to, will be cleared. entering the idle0 mode there is only one way for the device to enter the idle0 mode and t hat is to execute the 2 halt 2 instruction in the application program with the idlen bit in smod register equal to 2 1 2 and the fsyson bit in wdtc register equal to 2 0 2 . when this instruction is executed under the conditions described above, the following will occur: the system clock will be stopped and the application program w ill stop at the 2 halt 2 instruction, but the time base clock and f sub clock will be on. the data memory contents and registers will maintain their pr esent condition. the wdt will be cleared and resume counting if the wdt clock sou rce is selected to come from the f sub clock and the wdt is enabled. the wdt will stop if its clock sour ce originates from the system clock. the i/o ports will maintain their present conditions. in the status register, the power down flag, pdf, will be set an d the watchdog time-out flag, to, will be cleared. rev. 1.10 39 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
entering the idle1 mode there is only one way for the device to enter the idle1 mode and t hat is to execute the halt instruction in the application program with the idlen bit in smod register equal to 2 1 2 and the fsyson bit in the wdtc register equal to 2 1 2 . when this instruction is executed under the conditions described above, the following will occur: the system clock, time base clock and f sub clock will be on and the application program will stop at t he 2 halt 2 instruction. the data memory contents and registers will maintain their pr esent condition. the wdt will be cleared and resume counting if the wdt is enable d regardless of the wdt clock source which originates from the f sub clock or from the system clock. the i/o ports will maintain their present conditions. in the status register, the power down flag, pdf, will be set an d the watchdog time-out flag, to, will be cleared. standby current considerations as the main reason for entering the sleep or idle mode is to keep the current consumption of the device to as low a value as possible, perhaps only in the order of several micro-amps except in the idle1 mode, there are other considerations which must also be taken into account by the circuit designer if the power consumption is to be minimised. special attention must be made to the i/o pins on the device. all high-impedance input pins must be connected to either a fixed high or low level as any floating input pins could create internal oscillations and result in increased current consumption. this also applies to devices which have different package types, as there may be unbonbed pins. these must either be setup as outputs or if setup as inputs must have pull-high resistors connected. care must also be taken with the loads, which are connected to i/o pins, which are setup as outputs. these should be placed in a condition in which minimum current is drawn or connected only to external circuits that do not draw current, such as other cmos inputs. also note that additional standby current will also be required if the lirc oscillator have been enabled. in the idle1 mode the system oscillator is on, if the system oscillator is from the high speed system oscillator, the additional standby current will also be perhaps in the order of several hundred micro-amps. wake-up after the system enters the sleep or idle mode, it can be woken u p from one of various sources listed as follows: an external reset an external falling edge on port a a system interrupt a wdt overflow if the system is woken up by an external reset, the device will experience a full system reset, how - ever, if the device is woken up by a wdt overflow, a watchdog timer reset will be initiated. al - though both of these wake-up methods will initiate a reset operation, the actual source of the wake-up can be determined by examining the to and pdf flags. the pdf flag is cleared by a sys - tem power-up or executing the clear watchdog timer instructions and is set when executing the 2 halt 2 instruction. the to flag is set if a wdt time-out occurs, and causes a wake-up that only re - sets the program counter and stack pointer, the other flags remain in their original status. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 40 february 9, 2011
each pin on port a can be setup using the pawu register to permit a negative transition on the pin to wake-up the system. when a port a pin wake-up occurs, the program will resume execution at the instruction following the 2 halt 2 instruction. if the system is woken up by an interrupt, then two possible situations may occur. the first is where the related interrupt is disabled or the interrupt is enabled but the stack is full, in which case the program will resume execution at the instruction following the 2 halt 2 instruction. in this situation, the interrupt which woke-up the device will not be immediately serviced, but will rather be serviced later when the related interrupt is finally enabled or when a stack level becomes free. the other situation is where the related interrupt is enabled and the stack is not full, in which case the regular interrupt response takes place. if an interrupt request flag is set high before entering the sleep or idle mode, the wake-up function of the related interrupt will be disabled. programming considerations if the device is woken up from the sleep1 mode to normal mode, an d the system clock source is from the hxt oscillator and fsten is 2 1 2 , the system clock can first be switched to the lirc oscillator after wake up. there are peripheral functions, such as wdt and tms, for which the f sys is used. if the system clock s ource is switched from f h to f l , the clock source to the peripheral functions mentioned abov e will change accordingly. the on/off condition of f sub and f s depends upon whether the wdt is enabled or disabled as the wdt c lock source is selected from f sub . watchdog timer the watchdog timer is provided to prevent program malfunctio ns or sequences from jumping to unknown locations, due to certain uncontrollable external events such as electrical noise. watchdog timer clock source the watchdog timer clock source is provided by the internal cl ock, f s , which is in turn supplied by one o f two sources selected by configuration option: f sub or f sys /4. the f sub clock is sourced from the lirc o scillator. the lirc internal oscillator has an approximate period of 32khz at a supply voltage of 5v. however, it should be noted that this specified internal clock period can vary with v dd , temperature a nd process variations. the other watchdog timer clock source option is the f sys /4 clock. the w atchdog timer clock source can originate from the f sub clock, i.e. its own internal lirc oscillator or f sys /4 determined by a configuration option. the watchdog timer s ource clock is then subdivided by a ratio of 2 8 to 2 15 to give longer timeouts, the actual value being chosen using t he ws2~ws0 bits in the wdtc register. rev. 1.10 41 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
watchdog timer control register a single register, wdtc, controls the required timeout perio d as well as the enable/disable operation. this register together with several configuration options control the overall operation of the watchdog timer. wdtc register bit 7 6 5 4 3 2 1 0 name fsyson ws2 ws1 ws0 wdten3 wdten2 wdten1 wdten0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 1 1 1 1 0 1 0 bit 7 fsyson : f sys control in idle mode 0: disable 1: enable bit 6 ~ 4 ws2, ws1, ws0 : wdt time-out period selection 000: 256/f s 001: 512/f s 010: 1024/f s 011: 2048/f s 100: 4096/f s 101: 8192/f s 110: 16384/f s 111: 32768/f s bit 3 ~ 0 wdten3, wdten2, wdten1, wdten0 : wdt software control 1010: disable other: enable watchdog timer operation the watchdog timer operates by providing a device reset when i ts timer overflows. this means that in the application program and during normal operation the user has to strategically clear the watchdog timer before it overflows to prevent the watchdog timer from executing a reset. this is done using the clear watchdog instructions. if the program malfunctions for whatever reason, jumps to an unknown location, or enters an endless loop, these clear instructions will not be executed in the correct manner, in which case the watchdog timer will overflow and reset the device. some of the watchdog timer options, such as enable/disable, clock source selection and clear instruction type are selected using configuration options. in addition to a configuration option to enable/disable the watchdog timer, there are also four bits, wdten3~wdten0, in the wdtc register to offer an additional enable/disable control of the watchdog timer. to disable the watchdog timer, as well as the configuration option being set to disable, the wdten3 ~ wdten0 bits must also be set to a specific value of 1010b. any other values for these bits will keep the watchdog timer enabled, irrespective of the configuration enable/disable setting. after power on these bits will have the value of 1010. if the watchdog timer is used, it is recommended that they are set to a value of 0101b for maximum noise immunity. note that if the watchdog timer has been disabled, then any instruction relating to its operation will result in no operation. wdt configuration option wdten3~wdten0 bits wdt wdt enable xxxx enable wdt disable except 1010 enable wdt disable 1010 disable 2 x 2 : don t care. watchdog timer enable/disable control ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 42 february 9, 2011
under normal program operation, a watchdog timer time-out will initialise a device reset and set the status bit to. however, if the system is in the sleep or idle mode, when a watchdog timer time-out occurs, the to bit in the status register will be set and only the program counter and stack pointer will be reset. three methods can be adopted to clear the contents of the watchdog timer. the first is an external hardware reset, which means a low level on the res pin, the second is using the watchdog timer software clear instructions and the third is via a halt instruction. there are two methods of using software instructions to clear the watchdog timer, one of which must be chosen by configuration option. the first option is to use the single 2 clr wdt 2 instruction while the second is to use the two commands 2 clr wdt1 2 and 2 clr wdt2 2 . for the first option, a simple execution of 2 clr wdt 2 will clear the wdt while for the second option, both 2 clr wdt1 2 and 2 clr wdt2 2 must both be executed alternately to successfully clear the watchdog timer. note that for this second option, if 2 clr wdt1 2 is used to clear the watchdog timer, successive executions of this instruction will have no effect, only the execution of a 2 clr wdt2 2 instruction will clear the watchdog timer. similarly after the 2 clr wdt2 2 instruction has been executed, only a successive 2 clr wdt1 2 instruction can clear the watchdog timer. the maximum time out period is when the 2 15 division ratio is selected. as an example, with a 32khz l irc oscillator as its source clock, this will give a maximum watchdog period of around 1 second for the 2 15 division ratio, and a minimum timeout of 7.8ms for the 2 8 division ration. if the f sys /4 clock is u sed as the watchdog timer clock source, it should be noted that when the system enters the sleep or idle0 mode, then the instruction clock is stopped and the watchdog timer may lose its protecting purposes. for systems that operate in noisy environments, using the f sub clock source is strongly r ecommended. rev. 1.10 43 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu 8 - s t a g e d i v i d e r f s w d t t i m e - o u t ( 2 8 / f s ~ 2 1 5 / f s ) f s / 2 8 w d t p r e s c a l e r 8 - t o - 1 m u x c l e a r w d t t y p e c o n f i g u r a t i o n o p t i o n c l r w d t 1 f l a g c l r w d t 2 f l a g 1 o r 2 i n s t r u c t i o n s c l r f s u b w s 2 ~ w s 0 ( f s / 2 8 ~ f s / 2 1 5 ) m u x f s y s / 4 c o n f i g u r a t i o n o p t i o n watchdog timer
reset and initialisation a reset function is a fundamental part of any microcontroller ensuring that the device can be set to some predetermined condition irrespective of outside parameters. the most important reset condition is after power is first applied to the microcontroller. in this case, internal circuitry will ensure that the microcontroller, after a short delay, will be in a well defined state and ready to execute the first program instruction. after this power-on reset, certain important internal registers will be set to defined states before the program commences. one of these registers is the program counter, which will be reset to zero forcing the microcontroller to begin program execution from the lowest program memory address. in addition to the power-on reset, situations may arise where it is necessary to forcefully apply a reset condition when the microcontroller is running. one example of this is where after power has been applied and the microcontroller is already running, the res line is forcefully pulled low. in such a case, known as a normal operation reset, some of the microcontroller registers remain unchanged allowing the microcontroller to precede with normal operation after the reset line is allowed to return high. another type of reset is when the watchdog timer overflows and resets the microcontroller. all types of reset operations result in different register conditions being setup. another reset exists in the form of a low voltage reset, lvr, where a full reset, similar to the res reset is implemented in situations where the power supply voltage falls below a certain threshold. reset functions there are five ways in which a microcontroller reset can occur , through events occurring both internally and externally: power-on reset the most fundamental and unavoidable reset is the one that occ urs after power is first applied to the microcontroller. as well as ensuring that the program memory begins execution from the first memory address, a power-on reset also ensures that certain other registers are preset to known conditions. all the i/o port and port control registers will power up in a high condition ensuring that all pins will be first set to inputs. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 44 february 9, 2011 r e s v d d i n t e r n a l r e s e t 0 . 9 v d d t r s t d + t s s t t r s t d + t s s t note: t rstd is power-on delay, typical time=100ms power-on reset timing chart
res pin reset as the reset pin is shared with pb.3, the reset function must be selected using a configuration option. although the microcontroller has an internal rc reset function, if the vdd power supply rise time is not fast enough or does not stabilise quickly at power-on, the internal reset function may be incapable of providing proper reset operation. for this reason it is recommended that an external rc network is connected to the res pin, whose additional time delay will ensure that the res pin remains low for an extended period to allow the power supply to stabilise. during this time delay, normal operation of the microcontroller will be inhibited. after the res line reaches a certain voltage value, the reset delay time t rstd is invoked to provide an extra delay time after which the m icrocontroller will begin normal operation. the abbreviation sst in the figures stands for system start-up timer. for most applications a resistor connected between vdd and the res pin and a capacitor connected between vss and the res pin will provide a suitable external reset circuit. any wiring connected to the res pin should be kept as short as possible to minimise any stray noise interference. for applications that operate within an environment where more noise is present the enhanced reset circuit shown is recommended. more information regarding external reset circuits is located in application note ha0075e on the holtek website. pulling the res pin low using external hardware will also execute a device reset. in this case, as in the case of other resets, the program counter will reset to zero and program execution initiated from this point. rev. 1.10 45 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu r e s i n t e r n a l r e s e t 0 . 9 v d d 0 . 4 v d d t r s t d + t s s t note: t rstd is power-on delay, typical time=100ms res reset timing chart p b 3 / r e s 0 . 1 ~ 1 m f 1 0 k w ~ 1 0 0 k w v d d v s s 0 . 0 1 m f * * v d d 1 n 4 1 4 8 * 3 0 0 w * note: 2*2 it is recommended that this component is added for added esd protection 2**2 it is recommended that this component is added in environments where power line noise is significant external res circuit
low voltage reset - lvr the microcontroller contains a low voltage reset circuit in o rder to monitor the supply voltage of the device. the lvr function is selected via a configuration option. if the supply voltage of the device drops to within a range of 0.9v~v lvr such as might occur when changing the battery, the lvr will a utomatically reset the device internally. for a valid lvr signal, a low supply voltage, i.e., a voltage in the range between 0.9v~v lvr must exist for a time greater than that specified by t lvr in the a.c. characteristics. i f the low supply voltage state does not exceed this value, the lvr will ignore the low supply voltage and will not perform a reset function. the actual v lvr value can be selected via configuration options. watchdog time-out reset during normal operation the watchdog time-out reset during normal operation is the sa me as a hardware res pin reset except that the watchdog time-out flag to will be set to 2 1 2 . watchdog time-out reset during sleep or idle mode the watchdog time-out reset during sleep or idle mode is a litt le different from other kinds of reset. most of the conditions remain unchanged except that the program counter and the stack pointer will be cleared to 2 0 2 and the to flag will be set to 2 1 2 . refer to the a.c. characteristics for t sst details. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 46 february 9, 2011 l v r i n t e r n a l r e s e t t r s t d + t s s t note: t rstd is power-on delay, typical time=100ms low v oltage reset timing chart t r s t d + t s s t w d t t i m e - o u t i n t e r n a l r e s e t note: t rstd is power-on delay, typical time=100ms wdt time-out reset during normal operation timing chart t s s t w d t t i m e - o u t i n t e r n a l r e s e t note: the t sst is 15~16 clock cycles if the system clock source is provided by erc or hirc. the t sst is 1024 clock for hxt. the t sst is 1~2 clock for lirc. wdt time-out reset during sleep or idle timing chart
reset initial conditions the different types of reset described affect the reset flags in different ways. these flags, known as pdf and to are located in the status register and are controlled by various microcontroller operations, such as the sleep or idle mode function or watchdog timer. the reset flags are shown in the table: to pdf reset conditions 0 0 power-on reset u u res or lvr reset during normal or slow mode operation 1 u wdt time-out reset during normal or slow mode operation 1 1 wdt time-out reset during idle or sleep mode operation note: 2 u 2 stands for unchanged the following table indicates the way in which the various components of the microcontroller are af - fected after a power-on reset occurs. item condition after reset program counter reset to zero interrupts all interrupts will be disabled wdt clear after reset, wdt begins counting timer/event counter timer counter will be turned off input/output ports i/o ports will be setup as inputs, and an0~an3 in as a/d input pin. stack pointer stack pointer will point to the top of the stack the different kinds of resets all affect the internal registers of the microcontroller in different ways. to ensure reliable continuation of normal program execution after a reset occurs, it is important to know what condition the microcontroller is in after a particular reset occurs. the following table de- scribes how each type of reset affects each of the microcontroller internal registers. ht66f13 register register reset (power-on) res or lvr reset wdt time-out (normal operation) wdt time-out (idle) mp0 1 x x x x x x x 1 x x x x x x x 1 x x x x x x x 1 u u u u u u u mp1 1 x x x x x x x 1 x x x x x x x 1 x x x x x x x 1 u u u u u u u acc x x x x x x x x u u u u u u u u u u u u u u u u u u u u u u u u pcl 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 tblp x x x x x x x x u u u u u u u u u u u u u u u u u u u u u u u u tbhp - - - - - - x x - - - - - - u u - - - - - - u u - - - - - - u u tblh - - x x x x x x - - u u u u u u - - u u u u u u - - u u u u u u status - - 0 0 x x x x - - u u u u u u - - 1 u u u u u - - 1 1 u u u u smod 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 u u u u u u u u lvdc - - 0 0 - 0 0 0 - - 0 0 - 0 0 0 - - 0 0 - 0 0 0 - - u u - u u u integ - - - - 0 0 0 0 - - - - 0 0 0 0 - - - - 0 0 0 0 - - - - u u u u wdtc 0 1 1 1 1 0 1 0 0 1 1 1 1 0 1 0 0 1 1 1 1 0 1 0 u u u u u u u u tbc 0 0 1 1 - - - - 0 0 1 1 - - - - 0 0 1 1 - - - - u u u u - - - - rev. 1.10 47 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
register reset (power-on) res or lvr reset wdt time-out (normal operation) wdt time-out (idle) intc0 - 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 - u u u u u u u intc1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u pawu 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u papu 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u pa 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 u u u u u u u u pac 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 u u u u u u u u pbpu 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u pb 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 u u u u u u u u pbc 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 u u u u u u u u pcpu - - - - - - 0 0 - - - - - - 0 0 - - - - - - 0 0 - - - - - - u u pc - - - - - - 1 1 - - - - - - 1 1 - - - - - - 1 1 - - - - - - u u pcc - - - - - - 1 1 - - - - - - 1 1 - - - - - - 1 1 - - - - - - u u adrl (adrfs=0) x x x x - - - - x x x x - - - - x x x x - - - - u u u u - - - - adrl (adrfs=1) x x x x x x x x x x x x x x x x x x x x x x x x u u u u u u u u adrh (adrfs=0) x x x x x x x x x x x x x x x x x x x x x x x x u u u u u u u u adrh (adrfs=1) - - - - x x x x - - - - x x x x - - - - x x x x - - - - u u u u adcr0 0 1 1 0 - - 0 0 0 1 1 0 - - 0 0 0 1 1 0 - - 0 0 u u u u - - u u adcr1 0 0 - 0 - 0 0 0 0 0 - 0 - 0 0 0 0 0 - 0 - 0 0 0 u u - u - u u u acer - - - - 1 1 1 1 - - - - 1 1 1 1 - - - - 1 1 1 1 - - - - u u u u tmpc - - 0 1 - - - - - - 0 1 - - - - - - 0 1 - - - - - - u u - - - - tm1c0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u tm1c1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u tm1dl 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u tm1dh - - - - - - 0 0 - - - - - - 0 0 - - - - - - 0 0 - - - - - - u u tm1al 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u tm1ah - - - - - - 0 0 - - - - - - 0 0 - - - - - - 0 0 - - - - - - u u scomc 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u note: 2u2 stands for unchanged 2x2 stands for unknown 2-2 stands for unimplemented ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 48 february 9, 2011
ht66f14 register register reset (power-on) res or lvr reset wdt time-out (normal operation) wdt time-out (idle) mp0 x x x x x x x x x x x x x x x x x x x x x x x x u u u u u u u u mp1 x x x x x x x x x x x x x x x x x x x x x x x x u u u u u u u u acc x x x x x x x x u u u u u u u u u u u u u u u u u u u u u u u u pcl 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 tblp x x x x x x x x u u u u u u u u u u u u u u u u u u u u u u u u tblh - x x x x x x x - u u u u u u u - u u u u u u u - u u u u u u u tbhp - - - - - x x x - - - - - u u u - - - - - u u u - - - - - u u u status - - 0 0 x x x x - - u u u u u u - - 1 u u u u u - - 1 1 u u u u smod 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 u u u u u u u u lvdc - - 0 0 - 0 0 0 - - 0 0 - 0 0 0 - - 0 0 - 0 0 0 - - u u - u u u integ - - - - 0 0 0 0 - - - - 0 0 0 0 - - - - 0 0 0 0 - - - - u u u u wdtc 0 1 1 1 1 0 1 0 0 1 1 1 1 0 1 0 0 1 1 1 1 0 1 0 u u u u u u u u tbc 0 0 1 1 - - - - 0 0 1 1 - - - - 0 0 1 1 - - - - u u u u - - - - intc0 - 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 - u u u u u u u intc1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u mfi0 - - 0 0 - - 0 0 - - 0 0 - - 0 0 - - 0 0 - - 0 0 - - u u - - u u mfi1 - - 0 0 - - 0 0 - - 0 0 - - 0 0 - - 0 0 - - 0 0 - - u u - - u u pawu 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u papu 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u pa 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 u u u u u u u u pac 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 u u u u u u u u pbpu 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u pb 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 u u u u u u u u pbc 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 u u u u u u u u pcpu - - - - 0 0 0 0 - - - - 0 0 0 0 - - - - 0 0 0 0 - - - - u u u u pc - - - - 1 1 1 1 - - - - 1 1 1 1 - - - - 1 1 1 1 - - - - u u u u pcc - - - - 1 1 1 1 - - - - 1 1 1 1 - - - - 1 1 1 1 - - - - u u u u pdpu - - - - - - 0 0 - - - - - - 0 0 - - - - - - 0 0 - - - - - - u u pd - - - - - - 1 1 - - - - - - 1 1 - - - - - - 1 1 - - - - - - u u pdc - - - - - - 1 1 - - - - - - 1 1 - - - - - - 1 1 - - - - - - u u adrl (adrfs=0) x x x x - - - - x x x x - - - - x x x x - - - - u u u u - - - - adrl (adrfs=1) x x x x x x x x x x x x x x x x x x x x x x x x u u u u u u u u adrh (adrfs=0) x x x x x x x x x x x x x x x x x x x x x x x x u u u u u u u u adrh (adrfs=1) - - - - x x x x - - - - x x x x - - - - x x x x - - - - u u u u adcr0 0 1 1 0 - - 0 0 0 1 1 0 - - 0 0 0 1 1 0 - - 0 0 u u u u - - u u adcr1 0 0 - 0 - 0 0 0 0 0 - 0 - 0 0 0 0 0 - 0 - 0 0 0 u u - u - u u u rev. 1.10 49 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
register reset (power-on) res or lvr reset wdt time-out (normal operation) wdt time-out (idle) acer - - - - 1 1 1 1 - - - - 1 1 1 1 - - - - 1 1 1 1 - - - - u u u u tmpc - - 0 1 - - 0 1 - - 0 1 - - 0 1 - - 0 1 - - 0 1 - - u u - - u u tm0c0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u tm0c1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u tm0dl 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u tm0dh - - - - - - 0 0 - - - - - - 0 0 - - - - - - 0 0 - - - - - - u u tm0al 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u tm0ah - - - - - - 0 0 - - - - - - 0 0 - - - - - - 0 0 - - - - - - u u tm1c0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u tm1c1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u tm1dl 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u tm1dh - - - - - - 0 0 - - - - - - 0 0 - - - - - - 0 0 - - - - - - u u tm1al 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u tm1ah - - - - - - 0 0 - - - - - - 0 0 - - - - - - 0 0 - - - - - - u u scomc 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u note: 2u2 stands for unchanged 2x2 stands for unknown 2-2 stands for unimplemented ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 50 february 9, 2011
HT66F15 register register reset (power-on) res or lvr reset wdt time-out (normal operation) wdt time-out (idle) mp0 x x x x x x x x x x x x x x x x x x x x x x x x u u u u u u u u mp1 x x x x x x x x x x x x x x x x x x x x x x x x u u u u u u u u acc x x x x x x x x u u u u u u u u u u u u u u u u u u u u u u u u pcl 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 tblp x x x x x x x x u u u u u u u u u u u u u u u u u u u u u u u u tblh - x x x x x x x - u u u u u u u - u u u u u u u - u u u u u u u tbhp - - - - x x x x - - - - u u u u - - - - u u u u - - - - u u u u status - - 0 0 x x x x - - u u u u u u - - 1 u u u u u - - 1 1 u u u u smod 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 u u u u u u u u lvdc - - 0 0 - 0 0 0 - - 0 0 - 0 0 0 - - 0 0 - 0 0 0 - - u u - u u u integ - - - - 0 0 0 0 - - - - 0 0 0 0 - - - - 0 0 0 0 - - - - u u u u wdtc 0 1 1 1 1 0 1 0 0 1 1 1 1 0 1 0 0 1 1 1 1 0 1 0 u u u u u u u u tbc 0 0 1 1 - - - - 0 0 1 1 - - - - 0 0 1 1 - - - - u u u u - - - - intc0 - 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 - u u u u u u u intc1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u mfi0 - - 0 0 - - 0 0 - - 0 0 - - 0 0 - - 0 0 - - 0 0 - - u u - - u u mfi1 - 0 0 0 - 0 0 0 - 0 0 0 - 0 0 0 - 0 0 0 - 0 0 0 - u u u - u u u pawu 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u papu 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u pa 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 u u u u u u u u pac 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 u u u u u u u u pbpu 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u pb 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 u u u u u u u u pbc 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 u u u u u u u u pcpu 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u pc 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 u u u u u u u u pcc 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 u u u u u u u u pdpu - - - - - - 0 0 - - - - - - 0 0 - - - - - - 0 0 - - - - - - u u pd - - - - - - 1 1 - - - - - - 1 1 - - - - - - 1 1 - - - - - - u u pdc - - - - - - 1 1 - - - - - - 1 1 - - - - - - 1 1 - - - - - - u u adrl (adrfs=0) x x x x - - - - x x x x - - - - x x x x - - - - u u u u - - - - adrl (adrfs=1) x x x x x x x x x x x x x x x x x x x x x x x x u u u u u u u u adrh (adrfs=0) x x x x x x x x x x x x x x x x x x x x x x x x u u u u u u u u adrh (adrfs=1) - - - - x x x x - - - - x x x x - - - - x x x x - - - - u u u u adcr0 0 1 1 0 - - 0 0 0 1 1 0 - - 0 0 0 1 1 0 - - 0 0 u u u u - - u u adcr1 0 0 - 0 - 0 0 0 0 0 - 0 - 0 0 0 0 0 - 0 - 0 0 0 u u - u - u u u rev. 1.10 51 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
register reset (power-on) res or lvr reset wdt time-out (normal operation) wdt time-out (idle) acer - - - - 1 1 1 1 - - - - 1 1 1 1 - - - - 1 1 1 1 - - - - u u u u tmpc 1 0 0 1 - - 0 1 1 0 0 1 - - 0 1 1 0 0 1 - - 0 1 u u u u - - u u tm0c0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u tm0c1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u tm0dl 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u tm0dh - - - - - - 0 0 - - - - - - 0 0 - - - - - - 0 0 - - - - - - u u tm0al 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u tm0ah - - - - - - 0 0 - - - - - - 0 0 - - - - - - 0 0 - - - - - - u u tm1c0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u tm1c1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u tm1c2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u tm1dl 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u tm1dh - - - - - - 0 0 - - - - - - 0 0 - - - - - - 0 0 - - - - - - u u tm1al 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u tm1ah - - - - - - 0 0 - - - - - - 0 0 - - - - - - 0 0 - - - - - - u u tm1bl 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u tm1bh - - - - - - 0 0 - - - - - - 0 0 - - - - - - 0 0 - - - - - - u u scomc 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u u u u u u u u note: 2u2 stands for unchanged 2x2 stands for unknown 2-2 stands for unimplemented ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 52 february 9, 2011
input/output ports holtek microcontrollers offer considerable flexibility on their i/o ports. with the input or output designation of every pin fully under user program control, pull-high selections for all ports and wake-up selections on certain pins, the user is provided with an i/o structure to meet the needs of a wide range of application possibilities. the device provides bidirectional input/output lines labeled with port names pa~pd. these i/o ports are mapped to the ram data memory with specific addresses as shown in the special purpose data memory table. all of these i/o ports can be used for input and output operations. for input operation, these ports are non-latching, which means the inputs must be ready at the t2 rising edge of instruction 2 mov a,[m] 2 , where m denotes the port address. for output operation, all the data is latched and remains unchanged until the output latch is rewritten. i/o register list ht66f13 register name bit 7 6 5 4 3 2 1 0 pawu d7 d6 d5 d4 d3 d2 d1 d0 papu d7 d6 d5 d4 d3 d2 d1 d0 pa d7 d6 d5 d4 d3 d2 d1 d0 pac d7 d6 d5 d4 d3 d2 d1 d0 pbpu d7 d6 d5 d4 d3 d2 d1 d0 pb d7 d6 d5 d4 d3 d2 d1 d0 pbc d7 d6 d5 d4 d3 d2 d1 d0 pcpu ? ? ? ? ? ? d1 d0 pc ? ? ? ? ? ? d1 d0 pcc ? ? ? ? ? ? d1 d0 ht66f14 register name bit 7 6 5 4 3 2 1 0 pawu d7 d6 d5 d4 d3 d2 d1 d0 papu d7 d6 d5 d4 d3 d2 d1 d0 pa d7 d6 d5 d4 d3 d2 d1 d0 pac d7 d6 d5 d4 d3 d2 d1 d0 pbpu d7 d6 d5 d4 d3 d2 d1 d0 pb d7 d6 d5 d4 d3 d2 d1 d0 pbc d7 d6 d5 d4 d3 d2 d1 d0 pcpu ? ? ? ? d3 d2 d1 d0 pc ? ? ? ? d3 d2 d1 d0 pcc ? ? ? ? d3 d2 d1 d0 pdpu ? ? ? ? ? ? d1 d0 pd ? ? ? ? ? ? d1 d0 pdc ? ? ? ? ? ? d1 d0 rev. 1.10 53 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
HT66F15 register name bit 7 6 5 4 3 2 1 0 pawu d7 d6 d5 d4 d3 d2 d1 d0 papu d7 d6 d5 d4 d3 d2 d1 d0 pa d7 d6 d5 d4 d3 d2 d1 d0 pac d7 d6 d5 d4 d3 d2 d1 d0 pbpu d7 d6 d5 d4 d3 d2 d1 d0 pb d7 d6 d5 d4 d3 d2 d1 d0 pbc d7 d6 d5 d4 d3 d2 d1 d0 pcpu d7 d6 d5 d4 d3 d2 d1 d0 pc d7 d6 d5 d4 d3 d2 d1 d0 pcc d7 d6 d5 d4 d3 d2 d1 d0 pdpu ? ? ? ? ? ? d1 d0 pd ? ? ? ? ? ? d1 d0 pdc ? ? ? ? ? ? d1 d0 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 54 february 9, 2011 v d d m u x w a k e - u p s e l e c t s y s t e m w a k e - u p r e a d d a t a r e g i s t e r d q c k s d q c k s c o n t r o l b i t d a t a b u s w r i t e c o n t r o l r e g i s t e r c h i p r e s e t r e a d c o n t r o l r e g i s t e r w r i t e d a t a r e g i s t e r d a t a b i t i / o p i n q q p a o n l y w e a k p u l l - u p p u l l - h i g h r e g i s t e r s e l e c t generic input/output structure v d d m u x r e a d d a t a r e g i s t e r c o n t r o l b i t d a t a b u s w r i t e c o n t r o l r e g i s t e r c h i p r e s e t r e a d c o n t r o l r e g i s t e r w r i t e d a t a r e g i s t e r d a t a b i t a / d i n p u t p o r t a c s 4 , a c s 1 ~ a c s 0 t o a / d c o n v e r t e r w e a k p u l l - u p a n a l o g i n p u t s e l e c t o r d q c k s q d q c k s q p u l l - h i g h r e g i s t e r s e l e c t a/d input/output structure
pull-high resistors many product applications require pull-high resistors for t heir switch inputs usually requiring the use of an external resistor. to eliminate the need for these external resistors, all i/o pins, when configured as an input have the capability of being connected to an internal pull-high resistor. these pull-high resistors are selected using registers papu~pdpu and are implemented using weak pmos transistors. papu register bit 7 6 5 4 3 2 1 0 name d7 d6 d5 d4 d3 d2 d1 d0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 0 bit 7~0 i/o port a bit 7 ~ bit 0 pull-high control 0: disable 1: enable pbpu register bit 7 6 5 4 3 2 1 0 name d7 d6 d5 d4 d3 d2 d1 d0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 0 bit 7~0 i/o port b bit 7 ~ bit 0 pull-high control 0: disable 1: enable pcpu register - ht66f13 bit 7 6 5 4 3 2 1 0 name ? ? ? ? ? ? d1 d0 r/w ? ? ? ? ? ? r/w r/w por ? ? ? ? ? ? 0 0 bit 7~2 2?2 unimplemented, read as 202 bit 1~0 i/o port c bit 1 ~ bit 0 pull-high control 0: disable 1: enable pcpu register - ht66f14 bit 7 6 5 4 3 2 1 0 name ? ? ? ? d3 d2 d1 d0 r/w ? ? ? ? r/w r/w r/w r/w por ? ? ? ? 0 0 0 0 bit 7~4 2?2 unimplemented, read as 202 bit 3~0 i/o port c bit 3 ~ bit 0 pull-high control 0: disable 1: enable rev. 1.10 55 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
pcpu register - HT66F15 bit 7 6 5 4 3 2 1 0 name d7 d6 d5 d4 d3 d2 d1 d0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 0 bit 7~0 i/o port c bit 7 ~ bit 0 pull-high control 0: disable 1: enable pdpu register - ht66f14, HT66F15 bit 7 6 5 4 3 2 1 0 name ? ? ? ? ? ? d1 d0 r/w ? ? ? ? ? ? r/w r/w por ? ? ? ? ? ? 0 0 bit 7~2 2?2 unimplemented, read as 202 bit 1~0 i/o port d bit 1 ~ bit 0 pull-high control 0: disable 1: enable port a wake-up the halt instruction forces the microcontroller into the sle ep or idle mode which preserves power, a feature that is important for battery and other low-power applications. various methods exist to wake-up the microcontroller, one of which is to change the logic condition on one of the port a pins from high to low. this function is especially suitable for applications that can be woken up via external switches. each pin on port a can be selected individually to have this wake-up feature using the pawu register. pawu register bit 7 6 5 4 3 2 1 0 name d7 d6 d5 d4 d3 d2 d1 d0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 0 bit 7~0 pawu : port a bit 7 ~ bit 0 wake-up control 0: disable 1: enable i/o port control registers each i/o port has its own control register known as pac~pdc, to control the input/output configuration. with this control register, each cmos output or input can be reconfigured dynamically under software control. each pin of the i/o ports is directly mapped to a bit in its associated port control register. for the i/o pin to function as an input, the corresponding bit of the control register must be written as 1. this will then allow the logic state of the input pin to be directly read by instructions. when the corresponding bit of the control register is written as 0, the i/o pin will be setup as a cmos output. if the pin is currently setup as an output, instructions can still be used to read the output register. however, it should be noted that the program will in fact only read the status of the output data latch and not the actual logic status of the output pin. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 56 february 9, 2011
pac register bit 7 6 5 4 3 2 1 0 name d7 d6 d5 d4 d3 d2 d1 d0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 1 1 1 1 1 1 1 1 bit 7~0 i/o port a bit 7 ~ bit 0 input/output control 0: output 1: input pbc register bit 7 6 5 4 3 2 1 0 name d7 d6 d5 d4 d3 d2 d1 d0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 1 1 1 1 1 1 1 1 bit 7~0 i/o port b bit 7 ~ bit 0 input/output control 0: output 1: input pcc register - ht66f13 bit 7 6 5 4 3 2 1 0 name ? ? ? ? ? ? d1 d0 r/w ? ? ? ? ? ? r/w r/w por ? ? ? ? ? ? 1 1 bit 7~2 2?2 unimplemented, read as 202 bit 1~0 i/o port c bit 1 ~ bit 0 input/output control 0: output 1: input pcc register - ht66f14 bit 7 6 5 4 3 2 1 0 name ? ? ? ? d3 d2 d1 d0 r/w ? ? ? ? r/w r/w r/w r/w por ? ? ? ? 1 1 1 1 bit 7~4 2?2 unimplemented, read as 202 bit 3~0 i/o port c bit 3 ~ bit 0 input/output control 0: output 1: input pcc register - HT66F15 bit 7 6 5 4 3 2 1 0 name d7 d6 d5 d4 d3 d2 d1 d0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 1 1 1 1 1 1 1 1 bit 7~0 i/o port c bit 7 ~ bit 0 input/output control 0: output 1: input rev. 1.10 57 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
pdc register - ht66f14, HT66F15 bit 7 6 5 4 3 2 1 0 name ? ? ? ? ? ? d1 d0 r/w ? ? ? ? ? ? r/w r/w por ? ? ? ? ? ? 0 0 bit 7~2 2?2 unimplemented, read as 202 bit 1~0 i/o port d bit 1 ~ bit 0 input/output control 0: output 1: input i/o pin structures the accompanying diagrams illustrate the internal structur es of some generic i/o pin types. as the exact logical construction of the i/o pin will differ from these drawings, they are supplied as a guide only to assist with the functional understanding of the i/o pins. the wide range of pin-shared structures does not permit all types to be shown. the diagrams illustrate the i/o pin internal structures. as the exact logical construction of the i/o pin may differ from these drawings, they are supplied as a guide only to assist with the functional understanding of the i/o pins. programming considerations within the user program, one of the first things to consider is port initialisation. after a reset, all of the i/o data and port control registers will be set high. this means that all i/o pins will default to an input state, the level of which depends on the other connected circuitry and whether pull-high selections have been chosen. if the port control registers, pac~pdc, are then programmed to setup some pins as outputs, these output pins will have an initial high output value unless the associated port data registers, pa~pd, are first programmed. selecting which pins are inputs and which are outputs can be achieved byte-wide by loading the correct values into the appropriate port control register or by programming individual bits in the port control register using the 2 set [m].i 2 and 2 clr [m].i 2 instructions. note that when using these bit control instructions, a read-modify-write operation takes place. the microcontroller must first read in the data on the entire port, modify it to the required new bit values and then rewrite this data back to the output ports. port a has the additional capability of providing wake-up functions. when the device is in the sleep or idle mode, various methods are available to wake the device up. one of these is a high to low transition of any of the port a pins. single or multiple pins on port a can be setup to have this function. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 58 february 9, 2011
timer modules  tm one of the most fundamental functions in any microcontroller device is the ability to control and measure time. to implement time related functions each device includes several timer modules, abbreviated to the name tm. the tms are multi-purpose timing units and serve to provide operations such as timer/counter, input capture, compare match output and single pulse output as well as being the functional unit for the generation of pwm signals. each of the tms has either two or three individual interrupts. the addition of input and output pins for each tm ensures that users are provided with timing units with a wide and flexible range of features. the common features of the different tm types are described here with more detailed information provided in the individual compact, standard and enhanced tm sections. introduction the devices contain up to two tms with each tm having a reference name of tm0 and tm1. each individual tm can be categorised as a certain type, namely compact type tm (ctm), standard type tm (stm) or enhanced type tm (etm). although similar in nature, the different tm types vary in their feature complexity. the common features to all of the compact, standard and enhanced tms will be described in this section and the detailed operation regarding each of the tm types will be described in separate sections. the main features and differences between the three types of tms are summarised in the accompanying table. function ctm stm etm timer/counter  i/p capture   compare match output  pwm channels 1 1 2 single pulse output  12 pwm alignment edge edge edge & centre pwm adjustment period & duty duty or period duty or period duty or period tm function summary each device in the series contains a specific number of either compact type, standard type and en - hanced type tm units which are shown in the table together with their individual reference name, tm0~tm1. device tm0 tm1 ht66f13  10-bit stm ht66f14 10-bit ctm 10-bit stm HT66F15 10-bit ctm 10-bit etm tm name/type reference rev. 1.10 59 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
tm operation the three different types of tm offer a diverse range of functions, from simple timing operations to pwm signal generation. the key to understanding how the tm operates is to see it in terms of a free running counter whose value is then compared with the value of pre-programmed internal comparators. when the free running counter has the same value as the pre-programmed comparator, known as a compare match situation, a tm interrupt signal will be generated which can clear the counter and perhaps also change the condition of the tm output pin. the internal tm counter is driven by a user selectable clock source, which can be an internal clock or an external pin. tm clock source the clock source which drives the main counter in each tm can originate from various sources. the selection of the required clock source is implemented using the tnck2~tnck0 bits in the tm control registers. the clock source can be a ratio of either the system clock f sys or the high speed clock f h , the f tbc clock source or the external tckn pin. note that setting these bits to the value 101 will select a reserved clock input, in effect disconnecting the tm clock source. the tckn pin clock source is used to allow an external signal to drive the tm as an external clock source or for event counting. tm interrupts the compact and standard type tms each have two internal interrupts, one for each of the internal comparator a or comparator p, which generate a tm interrupt when a compare match condition occurs. as the enhanced type tm has three internal comparators and comparator a or comparator b or comparator p compare match functions, it consequently has three internal interrupts. when a tm interrupt is generated it can be used to clear the counter and also to change the state of the tm output pin. tm external pins each of the tms, irrespective of what type, has one tm input pin, with the label tckn. the tm input pin, is essentially a clock source for the tm and is selected using the tnck2~tnck0 bits in the tmnc0 register. this external tm input pin allows an external clock source to drive the internal tm. this external tm input pin is shared with other functions but will be connected to the internal tm if selected using the tnck2~tnck0 bits. the tm input pin can be chosen to have either a rising or falling active edge. the tms each have one or more output pins with the label tpn. when the tm is in the compare match output mode, these pins can be controlled by the tm to switch to a high or low level or to toggle when a compare match situation occurs. the external tpn output pin is also the pin where the tm generates the pwm output waveform. as the tm output pins are pin-shared with other function, the tm output function must first be setup using registers. a single bit in one of the registers determines if its associated pin is to be used as an external tm output pin or if it is to have another function. the number of output pins for each tm type and device is different, the details are provided in the accompanying table. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 60 february 9, 2011
all tm output pin names have an  _n suffix. pin names that include a  _1 or  _2 suffix indicate that they are from a tm with multiple output pins. this allows the tm to generate a complimentary output pair, selected using the i/o register data bits. device ctm stm etm registers ht66f13  tp1_0, tp1_1  tmpc ht66f14 tp0_0, tp0_1 tp1_0, tp1_1  tmpc HT66F15 tp0_0, tp0_1  tp1a, tp1b_0, tp1b_1, tp1b_2 tmpc tm output pins tm input/output pin control registers selecting to have a tm input/output or whether to retain its other shared function is implemented using one register, with a single bit in each register corresponding to a tm input/output pin. setting the bit high will setup the corresponding pin as a tm input/output, if reset to zero the pin will retain its original other function. tmpc register device bit 76543210 ht66f13  t1cp1 t1cp0  ht66f14  t1cp1 t1cp0  t0cp1 t0cp0 HT66F15 t1acp0 t1bcp2 t1bcp1 t1bcp0  t0cp1 t0cp0 tm input/output pin control registers list rev. 1.10 61 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 62 february 9, 2011          
                                                                              
                                ht66f13 tm function pin control block diagram note: 1. the i/o register data bits shown are used for tm output inversion control. 2. in the capture input mode, the tm pin control register must never enable more than one tm input.
rev. 1.10 63 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu          
                                                                              
                                                               
                                      
                        ht66f14 tm0 & tm1 function pin control block diagram note: 1. the i/o register data bits shown are used for tm output inversion control. 2. in the capture input mode, the tm pin control register must never enable more than one tm input.
ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 64 february 9, 2011                  
                                                     
                                                       
                                  
                                            
                                                                  
                                      
                        HT66F15 tm0 & tm1 function pin control block diagram note: 1. the i/o register data bits shown are used for tm output inversion control. 2. in the capture input mode, the tm pin control register must never enable more than one tm input.
tmpc register  ht66f13 bit76543210 name  t1cp1 t1cp0  r/w  r/w r/w  por  01  bit 7, 6 unimplemented, read as 0 bit 5 t1cp1 : tp1_1 pin enable control 0: disable 1: enable bit 4 t1cp0 : tp1_0 pin enable control 0: disable 1: enable bit 3~0 unimplemented, read as 0 tmpc register  ht66f14 bit76543210 name  t1cp1 t1cp0  t0cp1 t0cp0 r/w  r/w r/w  r/w r/w por  01  01 bit 7~6 unimplemented, read as 0 bit 5 t1cp1 : tp1_1 pin enable control 0: disable 1: enable bit 4 t1cp0 : tp1_0 pin enable control 0: disable 1: enable bit 3~2 unimplemented, read as 0 bit 1 t0cp1 : tp0_1 pin enable control 0: disable 1: enable bit 0 t0cp0 : tp0_0 pin enable control 0: disable 1: enable rev. 1.10 65 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
tmpc register  HT66F15 bit76543210 name t1acp0 t1bcp2 t1bcp1 t1bcp0  t0cp1 t0cp0 r/w r/w r/w r/w r/w  r/w r/w por1001  01 bit 7 t1acp0 : tp1a pin enable control 0: disable 1: enable bit 6 t1bcp2 : tp1b_2 pin enable control 0: disable 1: enable bit 5 t1bcp1 : tp1b_1 pin enable control 0: disable 1: enable bit 4 t1bcp0 : tp1b_0 pin enable control 0: disable 1: enable bit 3~2 unimplemented, read as 0 bit 1 t0cp1 : tp0_1 pin enable control 0: disable 1: enable bit 0 t0cp0 : tp0_0 pin enable control 0: disable 1: enable programming considerations the tm counter registers and the capture/compare ccra and ccrb registers, being either 10-bit or 16-bit, all have a low and high byte structure. the high bytes can be directly accessed, but as the low bytes can only be accessed via an internal 8-bit buffer, reading or writing to these register pairs must be carried out in a specific way. the important point to note is that data transfer to and from the 8-bit buffer and its related low byte only takes place when a write or read operation to its corresponding high byte is executed. as the ccra and ccrb registers are implemented in the way shown in the following diagram and accessing these register pairs is carried out in a specific way as described above, it is recommended to use the  mov instruction to access the ccra and ccrb low byte registers, named tmxal and tmxbl, using the following access procedures. accessing the ccra or ccrb low byte registers without following these access procedures will result in unpredictable values. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 66 february 9, 2011 data bus 8-bit buffer tmxdh tmxdl tmxbh tmxbl tmxah tmxal tm counter register (read only) tm ccra register (read/write) tm ccrb register (read/write)
the following steps show the read and write procedures: writing data to ccrb or ccra step 1. write data to low byte tmxal or tmxbl - n ote that here data is only written to the 8-bit buffer. step 2. write data to high byte tmxah or tmxbh - h ere data is written directly to the high byte registers and simultaneously data is latched from the 8-bit buffer to the low byte registers. reading data from the counter registers and ccrb or ccra step 1. read data from the high byte tmxdh, tmxah or tmxbh - h ere data is read directly from the high byte registers and simultaneously data is latched from the low byte register into the 8-bit buffer. step 2. read data from the low byte tmxdl, tmxal or tmxbl - t his step reads data from the 8-bit buffer. compact type tm - ctm although the simplest form of the three tm types, the compact t m type still contains three operating modes, which are compare match output, timer/event counter and pwm output modes. the compact tm can also be controlled with an external input pin and can drive one or two external output pins. these two external output pins can be the same signal or the inverse signal. ctm name tm no. tm input pin tm output pin ht66f13 ? ? ? ? ht66f14, HT66F15 10-bit ctm 0 tck0 tp0_0, tp0_1 compact tm operation at its core is a 10-bit count-up counter which is driven by a use r selectable internal or external clock source. there are also two internal comparators with the names, comparator a and comparator p. these comparators will compare the value in the counter with ccrp and ccra registers. the ccrp is three bits wide whose value is compared with the highest three bits in the counter while the ccra is the ten bits and therefore compares with all counter bits. rev. 1.10 67 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu c c r p c c r a t n c c l r c o m p a r a t o r p m a t c h c o m p a r a t o r a m a t c h t n c k 2 ~ t n c k 0 t n o n t n p a u b 7 ~ b 9 3 - b i t c o m p a r a t o r p t c k n 1 0 - b i t c o m p a r a t o r a c o u n t e r c l e a r 1 0 - b i t c o u n t - u p c o u n t e r t n p f i n t e r r u p t t n a f i n t e r r u p t t p n p i n o u t p u t b 0 ~ b 9 t n m 1 , t n m 0 t n i o 1 , t n i o 0 t n p o l t n o c p o l a r i t y c o n t r o l o u t p u t c o n t r o l t p n _ 0 t p n _ 1 1 1 1 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 f s y s / 4 f s y s f h / 1 6 f h / 6 4 f t b c r e s e r v e d 0 1 compact type tm block diagram
the only way of changing the value of the 10-bit counter using the application program, is to clear the counter by changing the tnon bit from low to high. the counter will also be cleared automatically by a counter overflow or a compare match with one of its associated comparators. when these conditions occur, a tm interrupt signal will also usually be generated. the compact type tm can operate in a number of different operational modes, can be driven by different clock sources including an input pin and can also control an output pin. all operating setup conditions are selected using relevant internal registers. compact type tm register description overall operation of the compact tm is controlled using six registers. a read only register pair exists to store the internal counter 10-bit value, while a read/write register pair exists to store the internal 10-bit ccra value. the remaining two registers are control registers which setup the different operating and control modes as well as the three ccrp bits. ctm register list  ht66f14/HT66F15 name bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 tm0c0 t0pau t0ck2 t0ck1 t0ck0 t0on t0rp2 t0rp1 t0rp0 tm0c1 t0m1 t0m0 t0io1 t0io0 t0oc t0pol t0dpx t0cclr tm0dl d7 d6 d5 d4 d3 d2 d1 d0 tm0dh  d9 d8 tm0al d7 d6 d5 d4 d3 d2 d1 d0 tm0ah  d9 d8 10-bit compact tm register list tm0dl register bit76543210 name d7 d6 d5 d4 d3 d2 d1 d0 r/wrrrrrrrr por00000000 bit 7~0 tm0dl : tm0 counter low byte register bit 7 ~ bit 0 tm0 10-bit counter bit 7 ~ bit 0 tm0dh register bit76543210 name  d9 d8 r/w  rr por  00 bit 7~2 unimplemented, read as 0 bit 1~0 tm0dh : tm0 counter high byte register bit 1 ~ bit 0 tm0 10-bit counter bit 9 ~ bit 8 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 68 february 9, 2011
tm0al register bit76543210 name d7 d6 d5 d4 d3 d2 d1 d0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por00000000 bit 7~0 tm0al : tm0 ccra low byte register bit 7 ~ bit 0 tm0 10-bit ccra bit 7 ~ bit 0 tm0ah register bit76543210 name  d9 d8 r/w  r/w r/w por  00 bit 7~2 unimplemented, read as 0 bit 1~0 tm0ah : tm0 ccra high byte register bit 1 ~ bit 0 tm0 10-bit ccra bit 9 ~ bit 8 tm0c0 register bit76543210 name t0pau t0ck2 t0ck1 t0ck0 t0on t0rp2 t0rp1 t0rp0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por00000000 bit 7 t0pau : tm0 counter pause control 0: run 1: pause the counter can be paused by setting this bit high. clearing the bit to zero restores normal counter operation. when in a pause condition the tm will remain powered up and continue to consume power. the counter will retain its residual value when this bit changes from low to high and resume counting from this value when the bit changes to a low value again. bit 6~4 t0ck2~t0ck0 : select tm0 counter clock 000: f sys /4 001: f sys 010: f h /16 011: f h /64 100: f tbc 101: undefined 110: tckn rising edge clock 111: tckn falling edge clock these three bits are used to select the clock source for the tm. selecting the reserved clock input will effectively disable the internal counter. the external pin clock source can be chosen to be active on the rising or falling edge. the clock source f sys is the system clock, while f h and f tbc are other internal clocks, the details of which can be found in the oscillator section. bit 3 t0on : tm0 counter on/off control 0: off 1: on this bit controls the overall on/off function of the tm. setting the bit high enables the counter to run, clearing the bit disables the tm. clearing this bit to zero will stop the counter from counting and turn off the tm which will reduce its power consumption. when the bit changes state from low to high the internal counter value will be reset to zero, however when the bit changes from high to low, the internal counter will retain its residual value. if the tm is in the compare match output mode then the tm output pin will be reset to its initial condition, as specified by the t0oc bit, when the t0on bit changes from low to high. rev. 1.10 69 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
bit 2~0 t0rp2~t0rp0 : tm0 ccrp 3-bit register, compared with the tm0 counter bit 9~bit 7 comparator p match period 000: 1024 tm0 clocks 001: 128 tm0 clocks 010: 256 tm0 clocks 011: 384 tm0 clocks 100: 512 tm0 clocks 101: 640 tm0 clocks 110: 768 tm0 clocks 111: 896 tm0 clocks these three bits are used to setup the value on the internal ccrp 3-bit register, which are then compared with the internal counter's highest three bits. the result of this comparison can be selected to clear the internal counter if the t0cclr bit is set to zero. setting the t0cclr bit to zero ensures that a compare match with the ccrp values will reset the internal counter. as the ccrp bits are only compared with the highest three counter bits, the compare values exist in 128 clock cycle multiples. clearing all three bits to zero is in effect allowing the counter to overflow at its maximum value. tm0c1 register bit76543210 name t0m1 t0m0 t0io1 t0io0 t0oc t0pol t0dpx t0cclr r/w r/w r/w r/w r/w r/w r/w r/w r/w por00000000 bit 7~6 t0m1~t0m0 : select tm0 operating mode 00: compare match output mode 01: undefined 10: pwm mode 11: timer/counter mode these bits setup the required operating mode for the tm. to ensure reliable operation the tm should be switched off before any changes are made to the t0m1 and t0m0 bits. in the timer/counter mode, the tm output pin control must be disabled. bit 5~4 t0io1~t0io0 : select tp0_0, tp0_1 output function compare match output mode 00: no change 01: output low 10: output high 11: toggle output pwm mode 00: pwm output inactive state 01: pwm output active state 10: pwm output 11: undefined timer/counter mode unused these two bits are used to determine how the tm output pin changes state when a certain condition is reached. the function that these bits select depends upon in which mode the tm is running. in the compare match output mode, the t0io1 and t0io0 bits determine how the tm output pin changes state when a compare match occurs from the comparator a. the tm output pin can be setup to switch high, switch low or to toggle its present state when a compare match occurs from the comparator a. when the bits are both zero, then no change will take place on the output. the initial value of the tm output pin should be setup using the t0oc bit in the tm0c1 register. note that the output level requested by the t0io1 and t0io0 bits must be different from the initial value setup using the t0oc bit otherwise no change will occur on the tm output pin when a compare match occurs. after the tm output pin changes state it can be reset to its initial level by changing the level of the t0on bit from low to high. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 70 february 9, 2011
in the pwm mode, the t0io1 and t0io0 bits determine how the tm output pin changes state when a certain compare match condition occurs. the pwm output function is modified by changing these two bits. it is necessary to change the values of the t0io1 and t0io0 bits only after the tmn has been switched off. unpredictable pwm outputs will occur if the t0io1 and t0io0 bits are changed when the tm is running bit 3 t0oc : tp0_0, tp0_1 output control bit compare match output mode 0: initial low 1: initial high pwm mode 0: active low 1: active high this is the output control bit for the tm output pin. its operation depends upon whether tm is being used in the compare match output mode or in the pwm mode. it has no effect if the tm is in the timer/counter mode. in the compare match output mode it determines the logic level of the tm output pin before a compare match occurs. in the pwm mode it determines if the pwm signal is active high or active low. bit 2 t0pol : tp0_0, tp0_1 output polarity control 0: non-invert 1: invert this bit controls the polarity of the tp0_0 or tp0_1 output pin. when the bit is set high the tm output pin will be inverted and not inverted when the bit is zero. it has no effect if the tm is in the timer/counter mode. bit 1 t0dpx : tm0 pwm period/duty control 0: ccrp - period; ccra - duty 1: ccrp - duty; ccra - period this bit, determines which of the ccra and ccrp registers are used for period and duty control of the pwm waveform. bit 0 t0cclr : select tm0 counter clear condition 0: tm0 comparatror p match 1: tm0 comparatror a match this bit is used to select the method which clears the counter. remember that the compact tm contains two comparators, comparator a and comparator p, either of which can be selected to clear the internal counter. with the t0cclr bit set high, the counter will be cleared when a compare match occurs from the comparator a. when the bit is low, the counter will be cleared when a compare match occurs from the comparator p or with a counter overflow. a counter overflow clearing method can only be implemented if the ccrp bits are all cleared to zero. the t0cclr bit is not used in the pwm mode. rev. 1.10 71 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
compact type tm operating modes the compact type tm can operate in one of three operating modes, compare match output mode, pwm mode or timer/counter mode. the operating mode is selected using the tnm1 and tnm0 bits in the tmnc1 register. compare match output mode to select this mode, bits tnm1 and tnm0 in the tmnc1 register, should be set to 00b respectively. in this mode once the counter is enabled and running it can be cleared by three methods. these are a counter overflow, a compare match from comparator a and a compare match from comparator p. when the tncclr bit is low, there are two ways in which the counter can be cleared. one is when a compare match occurs from comparator p, the other is when the ccrp bits are all zero which allows the counter to overflow. here both tnaf and tnpf interrupt request flags for the comparator a and comparator p respectively, will both be generated. if the tncclr bit in the tmnc1 register is high then the counter will be cleared when a compare match occurs from comparator a. however, here only the tnaf interrupt request flag will be generated even if the value of the ccrp bits is less than that of the ccra registers. therefore when tncclr is high no tnpf interrupt request flag will be generated. if the ccra bits are all zero, the counter will overflow when its reaches its maximum 10-bit, 3ff hex, value, however here the tnaf interrupt request flag will not be generated. as the name of the mode suggests, after a comparison is made, the tm output pin will change state. the tm output pin condition however only changes state when a tnaf interrupt request flag is generated after a compare match occurs from comparator a. the tnpf interrupt request flag, generated from a compare match occurs from comparator p, will have no effect on the tm output pin. the way in which the tm output pin changes state are determined by the condition of the tnio1 and tnio0 bits in the tmnc1 register. the tm output pin can be selected using the tnio1 and tnio0 bits to go high, to go low or to toggle from its present condition when a compare match occurs from comparator a. the initial condition of the tm output pin, which is setup after the tnon bit changes from low to high, is setup using the tnoc bit. note that if the tnio1 and tnio0 bits are zero then no pin change will take place. timer/counter mode to select this mode, bits tnm1 and tnm0 in the tmnc1 register should be set to 11 respectively. the timer/counter mode operates in an identical way to the compare match output mode generating the same interrupt flags. the exception is that in the timer/counter mode the tm output pin is not used. therefore the above description and timing diagrams for the compare match output mode can be used to understand its function. as the tm output pin is not used in this mode, the pin can be used as a normal i/o pin or other pin-shared function. pwm output mode to select this mode, bits tnm1 and tnm0 in the tmnc1 register should be set to 10 respectively. the pwm function within the tm is useful for applications which require functions such as motor control, heating control, illumination control etc. by providing a signal of fixed frequency but of varying duty cycle on the tm output pin, a square wave ac waveform can be generated with varying equivalent dc rms values. as both the period and duty cycle of the pwm waveform can be controlled, the choice of generated waveform is extremely flexible. in the pwm mode, the tncclr bit has no effect on the pwm operation. both of the ccra and ccrp registers are used to generate the pwm waveform, one register is used to clear the internal counter and thus control the pwm waveform frequency, while the other one is used to control the duty cycle. which register is used to control either frequency or duty cycle is determined using the tndpx bit in the tmnc1 register. the pwm waveform frequency and duty cycle can therefore be controlled by the values in the ccra and ccrp registers. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 72 february 9, 2011
rev. 1.10 73 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu counter value 0x3ff ccrp ccra tnon tnpau tnpol ccrp int. flag tnpf ccra int. flag tnaf tm o/p pin time ccrp=0 ccrp > 0 counter overflow ccrp > 0 counter cleared by ccrp value pause resume stop counter restart tncclr = 0; tnm [1:0] = 00 output pin set to initial level low if tnoc=0 output toggle with tnaf flag note tnio [1:0] = 10 active high output select here tnio [1:0] = 11 toggle output select output not affected by tnaf flag. remains high until reset by tnon bit output pin reset to initial value output controlled by other pin-shared function output inverts when tnpol is high compare match output mode -- tncclr = 0 note: 1. with tncclr=0, a comparator p match will clear the counter 2. the tm output pin is controlled only by the tnaf flag 3. the output pin is reset to its initial state by a tnon bit rising edge
ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 74 february 9, 2011 counter value 0x3ff ccrp ccra tnon tnpau tnpol ccrp int. flag tnpf ccra int. flag tnaf tm o/p pin time ccra=0 ccra = 0 counter overflow ccra > 0 counter cleared by ccra value pause resume stop counter restart tncclr = 1; tnm [1:0] = 00 output pin set to initial level low if tnoc=0 output toggle with tnaf flag note tnio [1:0] = 10 active high output select here tnio [1:0] = 11 toggle output select output not affected by tnaf flag. remains high until reset by tnon bit output pin reset to initial value output controlled by other pin-shared function output inverts when tnpol is high tnpf not generated no tnaf flag generated on ccra overflow output does not change compare match output mode -- tncclr = 1 note: 1. with tncclr=1, a comparator a match will clear the counter 2. the tm output pin is controlled only by the tnaf flag 3. the output pin is reset to its initial state by a tnon bit rising edge 4. the tnpf flag is not generated when tncclr=1
an interrupt flag, one for each of the ccra and ccrp, will be generated when a compare match occurs from either comparator a or comparator p. the tnoc bit in the tmnc1 register is used to select the required polarity of the pwm waveform while the two tnio1 and tnio0 bits are used to enable the pwm output or to force the tm output pin to a fixed high or low level. the tnpol bit is used to reverse the polarity of the pwm output waveform.  ctm, pwm mode, edge-aligned mode, t0dpx=0 ccrp 001b 010b 011b 100b 101b 110b 111b 000b period 128 256 384 512 640 768 896 1024 duty ccra if f sys = 16mhz, tm clock source is f sys /4, ccrp = 100b and ccra =128, the ctm pwm output frequency = (f sys /4)/512=f sys /2048 = 7.8125 khz, duty = 128/512 = 25%. if the duty value defined by the ccra register is equal to or greater than the period value, then the pwm output duty is 100%.  ctm, pwm mode, edge-aligned mode, t0dpx=1 ccrp 001b 010b 011b 100b 101b 110b 111b 000b period ccra duty 128 256 384 512 640 768 896 1024 the pwm output period is determined by the ccra register value together with the tm clock while the pwm duty cycle is defined by the ccrp register value. rev. 1.10 75 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu counter value ccrp ccra tnon tnpau tnpol ccrp int. flag tnpf ccra int. flag tnaf tm o/p pin (tnoc=1) time counter cleared by ccrp pause resume counter stop if tnon bit low counter reset when tnon returns high tndpx = 0; tnm [1:0] = 10 pwmdutycycle set by ccra pwm resumes operation output controlled by other pin-shared function output inverts when tnpol = 1 pwm period set by ccrp tm o/p pin (tnoc=0) pwm mode -- tndpx = 0 note: 1. here tndpx=0 -- counter cleared by ccrp 2. a counter clear sets the pwm period 3. the internal pwm function continues even when tnio [1:0] = 00 or 01 4. the tncclr bit has no influence on pwm operation
ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 76 february 9, 2011 counter value ccrp ccra tnon tnpau tnpol ccrp int. flag tnpf ccra int. flag tnaf tm o/p pin (tnoc=1) time counter cleared by ccra pause resume counter stop if tnon bit low counter reset when tnon returns high tndpx = 1; tnm [1:0] = 10 pwmdutycycle set by ccrp pwm resumes operation output controlled by other pin-shared function output inverts when tnpol = 1 pwm period set by ccra tm o/p pin (tnoc=0) pwm mode -- tndpx = 1 note: 1. here tndp x=1-- counter cleared by ccra 2. a counter clear sets the pwm period 3. the internal pwm function continues even when tnio [1:0] = 00 or 01 4. the tncclr bit has no influence on pwm operation
standard type tm  stm the standard type tm contains five operating modes, which are compare match output, timer/event counter, capture input, single pulse output and pwm output modes. the standard tm can also be controlled with an external input pin and can drive one or two external output pins. ctm name tm no. tm input pin tm output pin ht66f13/ht66f14 10-bit stm 1 tck1 tp1_0, tp1_1 HT66F15  standard tm operation at its core is a 10-bit count-up counter which is driven by a user selectable internal or external clock source. there are also two internal comparators with the names, comparator a and comparator p. these comparators will compare the value in the counter with ccrp and ccra registers. the ccrp is three bits wide whose value is compared with the highest three bits in the counter while the ccra is the ten bits and therefore compares with all counter bits. the only way of changing the value of the 10-bit counter using the application program, is to clear the counter by changing the tnon bit from low to high. the counter will also be cleared automatically by a counter overflow or a compare match with one of its associated comparators. when these conditions occur, a tm interrupt signal will also usually be generated. the standard type tm can operate in a number of different operational modes, can be driven by different clock sources including an input pin and can also control an output pin. all operating setup conditions are selected using relevant internal registers. rev. 1.10 77 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu               !          "   #   !           "   #     $       %    & '  $ ' ( ) * '     !           * '     !                 +      * '       *          
         
                     '  $ ' ( , - .  /           0       "  0   "      0              +    1      +           +                                    2 3 4 3   2 3 4 3 2 5    2 5    2      6   7  -   standard type tm block diagram
standard type tm register description overall operation of the standard tm is controlled using a series of registers. a read only register pair exists to store the internal counter 10-bit value, while a read/write register pair exists to store the internal 10-bit ccra value. the remaining two registers are control registers which setup the different operating and control modes as well as the three ccrp bits. stm register list  ht66f13/ ht66f14 name bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 tm1c0 t1pau t1ck2 t1ck1 t1ck0 t1on t1rp2 t1rp1 t1rp0 tm1c1 t1m1 t1m0 t1io1 t1io0 t1oc t1pol t1dpx t1cclr tm1dl d7 d6 d5 d4 d3 d2 d1 d0 tm1dh  d9 d8 tm1al d7 d6 d5 d4 d3 d2 d1 d0 tm1ah  d9 d8 10-bit standard tm register list tm1c0 register bit76543210 name t1pau t1ck2 t1ck1 t1ck0 t1on t1rp2 t1rp1 t1rp0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por00000000 bit 7 t1pau : tm1 counter pause control 0: run 1: pause the counter can be paused by setting this bit high. clearing the bit to zero restores normal counter operation. when in a pause condition the tm will remain powered up and continue to consume power. the counter will retain its residual value when this bit changes from low to high and resume counting from this value when the bit changes to a low value again. bit 6~4 t1ck2~t1ck0 : select tm1 counter clock 000: f sys /4 001: f sys 010: f h /16 011: f h /64 100: f tbc 101: undefined 110: tck1 rising edge clock 111: tck1 falling edge clock these three bits are used to select the clock source for the tm. selecting the reserved clock input will effectively disable the internal counter. the external pin clock source can be chosen to be active on the rising or falling edge. the clock source f sys is the system clock, while f h and f tbc are other internal clocks, the details of which can be found in the oscillator section. bit 3 t1on : tm1 counter on/off control 0: off 1: on this bit controls the overall on/off function of the tm. setting the bit high enables the counter to run, clearing the bit disables the tm. clearing this bit to zero will stop the counter from counting and turn off the tm which will reduce its power consumption. when the bit changes state from low to high the internal counter value will be reset to zero, however when the bit changes from high to low, the internal counter will retain its residual value until the bit returns high again. if the tm is in the compare match output mode then the tm output pin will be reset to its initial condition, as specified by the t1oc bit, when the t1on bit changes from low to high. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 78 february 9, 2011
bit 2~0 t1rp2~t1rp0 : tm1 ccrp 3-bit register, compared with the tm1 counter bit 9~bit 7 comparator p match period 000: 1024 tm1 clocks 001: 128 tm1 clocks 010: 256 tm1 clocks 011: 384 tm1 clocks 100: 512 tm1 clocks 101: 640 tm1 clocks 110: 768 tm1 clocks 111: 896 tm1 clocks these three bits are used to setup the value on the internal ccrp 3-bit register, which are then compared with the internal counter's highest three bits. the result of this comparison can be selected to clear the internal counter if the t1cclr bit is set to zero. setting the t1cclr bit to zero ensures that a compare match with the ccrp values will reset the internal counter. as the ccrp bits are only compared with the highest three counter bits, the compare values exist in 128 clock cycle multiples. clearing all three bits to zero is in effect allowing the counter to overflow at its maximum value. tm1c1 register bit76543210 name t1m1 t1m0 t1io1 t1io0 t1oc t1pol t1dpx t1cclr r/w r/w r/w r/w r/w r/w r/w r/w r/w por00000000 bit 7~6 t1m1~t1m0 : select tm1 operating mode 00: compare match output mode 01: capture input mode 10: pwm mode or single pulse output mode 11: timer/counter mode these bits setup the required operating mode for the tm. to ensure reliable operation the tm should be switched off before any changes are made to the t1m1 and t1m0 bits. in the timer/counter mode, the tm output pin control must be disabled. bit 5~4 t1io1~t1io0 : select tp1_0, tp1_1 output function compare match output mode 00: no change 01: output low 10: output high 11: toggle output pwm mode/single pulse output mode 00: pwm output inactive state 01: pwm output active state 10: pwm output 11: single pulse output capture input mode 00: input capture at rising edge of tp1_0, tp1_1 01: input capture at falling edge of tp1_0, tp1_1 10: input capture at falling/rising edge of tp1_0, tp1_1 11: input capture disabled timer/counter mode: unused these two bits are used to determine how the tm output pin changes state when a certain condition is reached. the function that these bits select depends upon in which mode the tm is running. in the compare match output mode, the t1io1 and t1io0 bits determine how the tm output pin changes state when a compare match occurs from the comparator a. the tm output pin can be setup to switch high, switch low or to toggle its present state when a compare match occurs from the comparator a. when the bits are both zero, then no change will take place on the output. the initial value of the tm output pin should be setup using the t1oc bit in the tm1c1 register. note that the output level requested by the t1io1 and t1io0 bits must be different from rev. 1.10 79 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
the initial value setup using the t1oc bit otherwise no change will occur on the tm output pin when a compare match occurs. after the tm output pin changes state it can be reset to its initial level by changing the level of the t1on bit from low to high. in the pwm mode, the t1io1 and t1io0 bits determine how the tm output pin changes state when a certain compare match condition occurs. the pwm output function is modified by changing these two bits. it is necessary to change the values of the t1io1 and t1io0 bits only after the tm has been switched off. unpredictable pwm outputs will occur if the t1io1 and t1io0 bits are changed when the tm is running bit 3 t1oc : tp1_0, tp1_1 output control bit compare match output mode 0: initial low 1: initial high pwm mode/ single pulse output mode 0: active low 1: active high this is the output control bit for the tm output pin. its operation depends upon whether tm is being used in the compare match output mode or in the pwm mode/ single pulse output mode. it has no effect if the tm is in the timer/counter mode. in the compare match output mode it determines the logic level of the tm output pin before a compare match occurs. in the pwm mode it determines if the pwm signal is active high or active low. bit 2 t1pol : tp1_0, tp1_1 output polarity control 0: non-invert 1: invert this bit controls the polarity of the tp1_0 or tp1_1 output pin. when the bit is set high the tm output pin will be inverted and not inverted when the bit is zero. it has no effect if the tm is in the timer/counter mode. bit 1 t1dpx : tm1 pwm period/duty control 0: ccrp - period; ccra - duty 1: ccrp - duty; ccra - period this bit, determines which of the ccra and ccrp registers are used for period and duty control of the pwm waveform. bit 0 t1cclr : select tm1 counter clear condition 0: tm1 comparatror p match 1: tm1 comparatror a match this bit is used to select the method which clears the counter. remember that the standard tm contains two comparators, comparator a and comparator p, either of which can be selected to clear the internal counter. with the t1cclr bit set high, the counter will be cleared when a compare match occurs from the comparator a. when the bit is low, the counter will be cleared when a compare match occurs from the comparator p or with a counter overflow. a counter overflow clearing method can only be implemented if the ccrp bits are all cleared to zero. the t1cclr bit is not used in the pwm, single pulse or input capture mode. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 80 february 9, 2011
tm1dl register bit76543210 name d7 d6 d5 d4 d3 d2 d1 d0 r/wrrrrrrrr por00000000 bit 7~0 tm1dl : tm1 counter low byte register bit 7~bit 0 tm1 10-bit counter bit 7~bit 0 tm1dh register bit76543210 name  d9 d8 r/w  rr por  00 bit 7~2 unimplemented, read as 0 bit 1~0 tm1dh : tm1 counter high byte register bit 1~bit 0 tm1 10-bit counter bit 9~bit 8 tm1al register bit76543210 name d7 d6 d5 d4 d3 d2 d1 d0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por00000000 bit 7~0 tm1al : tm1 ccra low byte register bit 7~bit 0 tm1 10-bit ccra bit 7~bit 0 tm1ah registe bit76543210 name  d9 d8 r/w  r/w r/w por  00 bit 7~2 unimplemented, read as 0 bit 1~0 tm1ah : tm1 ccra high byte register bit 1~bit 0 tm1 10-bit ccra bit 9~bit 8 rev. 1.10 81 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
standard type tm operating modes the standard type tm can operate in one of five operating modes, compare match output mode, pwm mode, single pulse output mode, capture input mode or timer/counter mode. the operating mode is selected using the tnm1 and tnm0 bits in the tmnc1 register. compare match output mode to select this mode, bits tnm1 and tnm0 in the tmnc1 register, should be set to 00 respectively. in this mode once the counter is enabled and running it can be cleared by three methods. these are a counter overflow, a compare match from comparator a and a compare match from comparator p. when the tncclr bit is low, there are two ways in which the counter can be cleared. one is when a compare match from comparator p, the other is when the ccrp bits are all zero which allows the counter to overflow. here both tnaf and tnpf interrupt request flags for comparator a and comparator p respectively, will both be generated. if the tncclr bit in the tmnc1 register is high then the counter will be cleared when a compare match occurs from comparator a. however, here only the tnaf interrupt request flag will be generated even if the value of the ccrp bits is less than that of the ccra registers. therefore when tncclr is high no tnpf interrupt request flag will be generated. in the compare match output mode, the ccra can not be set to 0. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 82 february 9, 2011 counter value 0x3ff ccrp ccra tnon tnpau tnpol ccrp int. flag tnpf ccra int. flag tnaf tm o/p pin time ccrp=0 ccrp > 0 counter overflow ccrp > 0 counter cleared by ccrp value pause resume stop counter restart tncclr = 0; tnm [1:0] = 00 output pin set to initial level low if tnoc=0 output toggle with tnaf flag note tnio [1:0] = 10 active high output select here tnio [1:0] = 11 toggle output select output not affected by tnaf flag. remains high until reset by tnon bit output pin reset to initial value output controlled by other pin-shared function output inverts when tnpol is high compare match output mode -- tncclr = 0 note: 1. with tncclr=0 a comparator p match will clear the counter 2. the tm output pin is controlled only by the tnaf flag 3. the output pin is reset to itsinitial state by a tnon bit rising edge
as the name of the mode suggests, after a comparison is made, the tm output pin, will change state. the tm output pin condition however only changes state when a tnaf interrupt request flag is generated after a compare match occurs from comparator a. the tnpf interrupt request flag, generated from a compare match occurs from comparator p, will have no effect on the tm output pin. the way in which the tm output pin changes state are determined by the condition of the tnio1 and tnio0 bits in the tmnc1 register. the tm output pin can be selected using the tnio1 and tnio0 bits to go high, to go low or to toggle from its present condition when a compare match occurs from comparator a. the initial condition of the tm output pin, which is setup after the tnon bit changes from low to high, is setup using the tnoc bit. note that if the tnio1 and tnio0 bits are zero then no pin change will take place. timer/counter mode to select this mode, bits tnm1 and tnm0 in the tmnc1 register should be set to 11 respectively. the timer/counter mode operates in an identical way to the compare match output mode generating the same interrupt flags. the exception is that in the timer/counter mode the tm output pin is not used. therefore the above description and timing diagrams for the compare match output mode can be used to understand its function. as the tm output pin is not used in this mode, the pin can be used as a normal i/o pin or other pin-shared function. rev. 1.10 83 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu counter value 0x3ff ccrp ccra tnon tnpau tnpol ccrp int. flag tnpf ccra int. flag tnaf tm o/p pin time ccra=0 ccra = 0 counter overflow ccra > 0 counter cleared by ccra value pause resume stop counter restart tncclr = 1; tnm [1:0] = 00 output pin set to initial level low if tnoc=0 output toggle with tnaf flag note tnio [1:0] = 10 active high output select here tnio [1:0] = 11 toggle output select output not affected by tnaf flag. remains high until reset by tnon bit output pin reset to initial value output controlled by other pin-shared function output inverts when tnpol is high tnpf not generated no tnaf flag generated on ccra overflow output does not change compare match output mode -- tncclr = 1 note: 1. with tncclr=1 a comparator a match will clear the counter 2. the tm output pin is controlled only by the tnaf flag 3. the output pin is reset to its initial state by a tnon bit rising edge 4. a tnpf flag is not generated when tncclr=1
pwm output mode to select this mode, bits tnm1 and tnm0 in the tmnc1 register should be set to 10 respectively. the pwm function within the tm is useful for applications which require functions such as motor control, heating control, illumination control etc. by providing a signal of fixed frequency but of varying duty cycle on the tm output pin, a square wave ac waveform can be generated with varying equivalent dc rms values. as both the period and duty cycle of the pwm waveform can be controlled, the choice of generated waveform is extremely flexible. in the pwm mode, the tncclr bit has no effect on the pwm operation. both of the ccra and ccrp registers are used to generate the pwm waveform, one register is used to clear the internal counter and thus control the pwm waveform frequency, while the other one is used to control the duty cycle. which register is used to control either frequency or duty cycle is determined using the tndpx bit in the tmnc1 register. the pwm waveform frequency and duty cycle can therefore be controlled by the values in the ccra and ccrp registers. an interrupt flag, one for each of the ccra and ccrp, will be generated when a compare match occurs from either comparator a or comparator p. the tnoc bit in the tmnc1 register is used to select the required polarity of the pwm waveform while the two tnio1 and tnio0 bits are used to enable the pwm output or to force the tm output pin to a fixed high or low level. the tnpol bit is used to reverse the polarity of the pwm output waveform.  stm, pwm mode, edge-aligned mode, t0dpx=0 ccrp 001b 010b 011b 100b 101b 110b 111b 000b period 128 256 384 512 640 768 896 1024 duty ccra if f sys = 16mhz, tm clock source is f sys /4, ccrp = 100b and ccra =128, the stm pwm output frequency = (f sys /4)/512=f sys /2048 = 7.8125 khz, duty = 128/512 = 25%. if the duty value defined by the ccra register is equal to or greater than the period value, then the pwm output duty is 100%.  stm, pwm mode, edge-aligned mode, t0dpx=1 ccrp 001b 010b 011b 100b 101b 110b 111b 000b period ccra duty 128 256 384 512 640 768 896 1024 the pwm output period is determined by the ccra register value together with the tm clock while the pwm duty cycle is defined by the ccrp register value. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 84 february 9, 2011
rev. 1.10 85 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu counter value ccrp ccra tnon tnpau tnpol ccrp int. flag tnpf ccra int. flag tnaf tm o/p pin (tnoc=1) time counter cleared by ccrp pause resume counter stop if tnon bit low counter reset when tnon returns high tndpx = 0; tnm [1:0] = 10 pwm duty cycle set by ccra pwm resumes operation output controlled by other pin-shared function output inverts when tnpol = 1 pwm period set by ccrp tm o/p pin (tnoc=0) pwm mode -- tndpx = 0 note: 1. here tndpx=0 -- counter cleared by ccrp 2. a counter clear sets the pwm period 3. the internal pwm function continues running even when tnio [1:0] = 00 or 01 4. the tncclr bit has no influence on pwm operation
single pulse mode to select this mode, bits tnm1 and tnm0 in the tmnc1 register should be set to 10 respectively and also the tnio1 and tnio0 bits should be set to 11 respectively. the single pulse output mode, as the name suggests, will generate a single shot pulse on the tm output pin. the trigger for the pulse output leading edge is a low to high transition of the tnon bit, which can be implemented using the application program. however in the single pulse mode, the tnon bit can also be made to automatically change from low to high using the external tckn pin, which will in turn initiate the single pulse output. when the tnon bit transitions to a high level, the counter will start running and the pulse leading edge will be generated. the tnon bit should remain high when the pulse is in its active state. the generated pulse trailing edge will be generated when the tnon bit is cleared to zero, which can be implemented using the application program or when a compare match occurs from comparator a. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 86 february 9, 2011 counter value ccrp ccra tnon tnpau tnpol ccrp int. flag tnpf ccra int. flag tnaf tm o/p pin (tnoc=1) time counter cleared by ccra pause resume counter stop if tnon bit low counter reset when tnon returns high tndpx = 1; tnm [1:0] = 10 pwmdutycycle set by ccrp pwm resumes operation output controlled by other pin-shared function output inverts when tnpol = 1 pwm period set by ccra tm o/p pin (tnoc=0) pwm mode -- tndpx = 1 note: 1. here tndpx=1 -- counter cleared by ccra 2. a counter clear sets the pwm period 3. the internal pwm function continues even when tnio [1:0] = 00 or 01 4. the tncclr bit has no influence on pwm operation
however a compare match from comparator a will also automatically clear the tnon bit and thus generate the single pulse output trailing edge. in this way the ccra value can be used to control the pulse width. a compare match from comparator a will also generate a tm interrupt. the counter can only be reset back to zero when the tnon bit changes from low to high when the counter restarts. in the single pulse mode ccrp is not used. the tncclr and tndpx bits are not used in this mode. rev. 1.10 87 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu   - .  , - .    %  '       3  8    ! !  - 3 ,   9   % 9            6     %  '       3  8    ! !  -    9   % 9        "   #    !      + 6   8 -  #  :       ;  +      + .  , - .   "         single pulse generation counter value ccrp ccra tnon tnpau tnpol ccrp int. flag tnpf ccra int. flag tnaf tm o/p pin (tnoc=1) time counter stopped by ccra pause resume counter stops by software counter reset when tnon returns high tnm [1:0] = 10 ; tnio [1:0] = 11 pulse width set by ccra output inverts when tnpol = 1 no ccrp interrupts generated tm o/p pin (tnoc=0) tckn pin software trigger cleared by ccra match tckn pin trigger auto. set by tckn pin software trigger software clear software trigger software trigger single pulse mode note: 1. counter stopped by ccra 2. ccrp is not used 3. the pulse is triggered by the tckn pin or by setting the tnon bit high 4. a tckn pin active edge will automatically set the tnon bit high 5. in the single pulse mode, tnio [1:0] must be set to 11  and can not be changed.
capture input mode to select this mode bits tnm1 and tnm0 in the tmnc1 register should be set to 01 respectively. this mode enables external signals to capture and store the present value of the internal counter and can therefore be used for applications such as pulse width measurements. the external signal is supplied on the tpn_0 or tpn_1 pin, whose active edge can be either a rising edge, a falling edge or both rising and falling edges; the active edge transition type is selected using the tnio1 and tnio0 bits in the tmnc1 register. the counter is started when the tnon bit changes from low to high which is initiated using the application program. when the required edge transition appears on the tpn_0 or tpn_1 pin, the present value in the counter will be latched into the ccra registers and a tm interrupt generated. irrespective of what events occur on the tpn_0 or tpn_1 pin the counter will continue to free run until the tnon bit changes from high to low. when a ccrp compare match occurs, the counter will reset back to zero; in this way the ccrp value can be used to control the maximum counter value. when a ccrp compare match occurs from comparator p, a tm interrupt will also be generated. counting the number of overflow interrupt signals from the ccrp can be a useful method in measuring long pulse widths. the tnio1 and tnio0 bits can select the active trigger edge on the tpn_0 or tpn_1 pin to be a rising edge, falling edge or both edge types. if the tnio1 and tnio0 bits are both set high, then no capture operation will take place irrespective of what happens on the tpn_0 or tpn_1 pin, however it must be noted that the counter will continue to run. as the tpn_0 or tpn_1 pin is pin shared with other functions, care must be taken if the tm is in the input capture mode. this is because if the pin is setup as an output, then any transitions on this pin may cause an input capture operation to be executed. the tncclr and tndpx bits are not used in this mode. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 88 february 9, 2011 counter value yy ccrp tnon tnpau ccrp int. flag tnpf ccra int. flag tnaf ccra value time counter cleared by ccrp pause resume counter reset tnm [1:0] = 01 tm capture pin tpn_x xx counter stop tnio [1:0] value xx yy xx yy active edge active edge active edge 00 rising edge 01 fallin g edge 10 both edges 11 disable capture capture input mode note: 1.. tnm [1:0] = 01 and active edge set by the tnio [1:0] bits 2. a tm capture input pin active edge transfers the counter value to ccra 3. tncclr bit not used 4. no output function -- tnoc and tnpol bits are not used 5. ccrp determines the counter value and the counter has a maximum count value when ccrp is equal to zero.
enhanced type tm  etm the enhanced type tm contains five operating modes, which are compare match output, timer/event counter, capture input, single pulse output and pwm output modes. the enhanced tm can also be controlled with an external input pin and can drive three or four external output pins. ctm name tm no. tm input pin tm output pin ht66f13/ht66f14   HT66F15 10-bit etm 1 tck1 tp1a; tp1b_0, tp1b_1, tp1b_2 enhanced tm operation at its core is a 10-bit count-up/count-down counter which is driven by a user selectable internal or external clock source. there are three internal comparators with the names, comparator a, comparator b and comparator p. these comparators will compare the value in the counter with the ccra, ccrb and ccrp registers. the ccrp comparator is 3 bits wide whose value is compared with the highest 3 bits in the counter while ccra and ccrb are 10 bits wide and therefore compared with all counter bits. the only way of changing the value of the 10-bit counter using the application program, is to clear the counter by changing the tnon bit from low to high. the counter will also be cleared automatically by a counter overflow or a compare match with one of its associated comparators. when these conditions occur, a tm interrupt signal will also usually be generated. the enhanced type tm can operate in a number of different operational modes, can be driven by different clock sources including an input pin and can also control output pins. all operating setup conditions are selected using relevant internal registers. rev. 1.10 89 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu               !          "   #   !           "   #     $       %    & '  $ ' ( ) * '     !           * '    !                +      * '    &  /  <         
         
                     '  $ ' ( , - .  /            0         "  0    "       0                 +    1      +           +                               2 3 4 3   2 3 4 3 2 5    2 5    2      6   7  -  
                       "  0    "       0                 +    1      +           +       !           "   #   * '    !         , - .  /           0         *     *     *    enhanced type tm block diagram
enhanced type tm register description overall operation of the enhanced tm is controlled using a series of registers. a read only register pair exists to store the internal counter 10-bit value, while two read/write register pairs exist to store the internal 10-bit ccra and ccrb value. the remaining three registers are control registers which setup the different operating and control modes as well as the three ccrp bits. name bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 tm1c0 t1pau t1ck2 t1ck1 t1ck0 t1on t1rp2 t1rp1 t1rp0 tm1c1 t1am1 t1am0 t1aio1 t1aio0 t1aoc t1apol t1cdn t1cclr tm1c2 t1bm1 t1bm0 t1bio1 t1bio0 t1boc t1bpol t1pwm1 t1pwm0 tm1dl d7 d6 d5 d4 d3 d2 d1 d0 tm1dh  d9 d8 tm1al d7 d6 d5 d4 d3 d2 d1 d0 tm1ah  d9 d8 tm1bl d7 d6 d5 d4 d3 d2 d1 d0 tm1bh  d9 d8 10-bit enhanced tm register list tm1c0 register bit76543210 name t1pau t1ck2 t1ck1 t1ck0 t1on t1rp2 t1rp1 t1rp0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por00000000 bit 7 t1pau : tm1 counter pause control 0: run 1: pause the counter can be paused by setting this bit high. clearing the bit to zero restores normal counter operation. when in a pause condition the tm will remain powered up and continue to consume power. the counter will retain its residual value when this bit changes from low to high and resume counting from this value when the bit changes to a low value again. bit 6~4 t1ck2~t1ck0 : select tm1 counter clock 000: f sys /4 001: f sys 010: f h /16 011: f h /64 100: f tbc 101: undefined 110: tck1 rising edge clock 111: tck1 falling edge clock these three bits are used to select the clock source for the tm. selecting the reserved clock input will effectively disable the internal counter. the external pin clock source can be chosen to be active on the rising or falling edge. the clock source f sys is the system clock, while f h and f tbc are other internal clocks, the details of which can be found in the oscillator section. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 90 february 9, 2011
bit 3 t1on : tm1 counter on/off control 0: off 1: on this bit controls the overall on/off function of the tm. setting the bit high enables the counter to run, clearing the bit disables the tm. clearing this bit to zero will stop the counter from counting and turn off the tm which will reduce its power consumption. when the bit changes state from low to high the internal counter value will be reset to zero, however when the bit changes from high to low, the internal counter will retain its residual value until the bit returns high again. if the tm is in the compare match output mode then the tm output pin will be reset to its initial condition, as specified by the t1oc bit, when the t1on bit changes from low to high. bit 2~0 t1rp2~t1rp0 : tm1 ccrp 3-bit register, compared with the tm1 counter bit 9~bit 7 comparator p match period 000: 1024 tm1 clocks 001: 128 tm1 clocks 010: 256 tm1 clocks 011: 384 tm1 clocks 100: 512 tm1 clocks 101: 640 tm1 clocks 110: 768 tm1 clocks 111: 896 tm1 clocks these three bits are used to setup the value on the internal ccrp 3-bit register, which are then compared with the internal counter  s highest three bits. the result of this comparison can be selected to clear the internal counter if the t1cclr bit is set to zero. setting the t1cclr bit to zero ensures that a compare match with the ccrp values will reset the internal counter. as the ccrp bits are only compared with the highest three counter bits, the compare values exist in 128 clock cycle multiples. clearing all three bits to zero is in effect allowing the counter to overflow at its maximum value. tm1c1 register bit76543210 name t1am1 t1am0 t1aio1 t1aio0 t1aoc t1apol t1cdn t1cclr r/w r/w r/w r/w r/w r/w r/w r r/w por00000000 bit 7~6 t1am1~t1am0 : select tm1 ccra operating mode 00: compare match output mode 01: capture input mode 10: pwm mode or single pulse output mode 11: timer/counter mode these bits setup the required operating mode for the tm. to ensure reliable operation the tm should be switched off before any changes are made to the t1am1 and t1am0 bits. in the timer/counter mode, the tm output pin control must be disabled. bit 5~4 t1aio1~t1aio0 : select tp1a output function compare match output mode 00: no change 01: output low 10: output high 11: toggle output pwm mode/single pulse output mode 00: pwm output inactive state 01: pwm output active state 10: pwm output 11: single pulse output capture input mode 00: input capture at rising edge of tp1a 01: input capture at falling edge of tp1a 10: input capture at falling/rising edge of tp1a 11: input capture disabled rev. 1.10 91 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
timer/counter mode unused these two bits are used to determine how the tm output pin changes state when a certain condition is reached. the function that these bits select depends upon in which mode the tm is running. in the compare match output mode, the t1aio1 and t1aio0 bits determine how the tm output pin changes state when a compare match occurs from the comparator a. the tm output pin can be setup to switch high, switch low or to toggle its present state when a compare match occurs from the comparator a. when the bits are both zero, then no change will take place on the output. the initial value of the tm output pin should be setup using the t1aoc bit in the tm1c1 register. note that the output level requested by the t1aio1 and t1aio0 bits must be different from the initial value setup using the t1aoc bit otherwise no change will occur on the tm output pin when a compare match occurs. after the tm output pin changes state it can be reset to its initial level by changing the level of the t1on bit from low to high. in the pwm mode, the t1aio1 and t1aio0 bits determine how the tm output pin changes state when a certain compare match condition occurs. the pwm output function is modified by changing these two bits. it is necessary to change the values of the t1aio1 and t1aio0 bits only after the tm has been switched off. unpredictable pwm outputs will occur if the t1aio1 and t1aio0 bits are changed when the tm is running bit 3 t1aoc : tp1a output control bit compare match output mode 0: initial low 1: initial high pwm mode/ single pulse output mode 0: active low 1: active high this is the output control bit for the tm output pin. its operation depends upon whether tm is being used in the compare match output mode or in the pwm mode/ single pulse output mode. it has no effect if the tm is in the timer/counter mode. in the compare match output mode it determines the logic level of the tm output pin before a compare match occurs. in the pwm mode it determines if the pwm signal is active high or active low. bit 2 t1apol : tp1a output polarity control 0: non-invert 1: invert this bit controls the polarity of the tp1a output pin. when the bit is set high the tm output pin will be inverted and not inverted when the bit is zero. it has no effect if the tm is in the timer/counter mode. bit 1 t1cdn : tm1 counter count up or down flag 0: count up 1: count down bit 0 t1cclr : select tm1 counter clear condition 0: tm1 comparator p match 1: tm1 comparator a match this bit is used to select the method which clears the counter. remember that the enhanced tm contains three comparators, comparator a, comparator b and comparator p, but only comparator a or comparator pan be selected to clear the internal counter. with the t1cclr bit set high, the counter will be cleared when a compare match occurs from the comparator a. when the bit is low, the counter will be cleared when a compare match occurs from the comparator p or with a counter overflow. a counter overflow clearing method can only be implemented if the ccrp bits are all cleared to zero. the t1cclr bit is not used in the single pulse or input capture mode. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 92 february 9, 2011
tm1c2 register bit76543210 name t1bm1 t1bm0 t1bio1 t1bio0 t1boc t1bpol t1pwm1 t1pwm0 r/w r/w r/w r/w r/w r/w r/w r r/w por00000000 bit 7~6 t1bm1~t1bm0 : select tm1 ccrb operating mode 00: compare match output mode 01: capture input mode 10: pwm mode or single pulse output mode 11: timer/counter mode these bits setup the required operating mode for the tm. to ensure reliable operation the tm should be switched off before any changes are made to the t1bm1 and t1bm0 bits. in the timer/counter mode, the tm output pin control must be disabled. bit 5~4 t1bio1~t1bio0 : select tp1b_0, tp1b_1, tp1b_2 output function compare match output mode 00: no change 01: output low 10: output high 11: toggle output pwm mode/single pulse output mode 00: pwm output inactive state 01: pwm output active state 10: pwm output 11: single pulse output capture input mode 00: input capture at rising edge of tp1b_0, tp1b_1, tp1b_2 01: input capture at falling edge of tp1b_0, tp1b_1, tp1b_2 10: input capture at falling/rising edge of tp1b_0, tp1b_1, tp1b_2 11: input capture disabled timer/counter mode unused these two bits are used to determine how the tm output pin changes state when a certain condition is reached. the function that these bits select depends upon in which mode the tm is running. in the compare match output mode, the t1bio1 and t1bio0 bits determine how the tm output pin changes state when a compare match occurs from the comparator a. the tm output pin can be setup to switch high, switch low or to toggle its present state when a compare match occurs from the comparator a. when the bits are both zero, then no change will take place on the output. the initial value of the tm output pin should be setup using the t1boc bit in the tm1c2 register. note that the output level requested by the t1bio1 and t1bio0 bits must be different from the initial value setup using the t1boc bit otherwise no change will occur on the tm output pin when a compare match occurs. after the tm output pin changes state it can be reset to its initial level by changing the level of the t1on bit from low to high. in the pwm mode, the t1bio1 and t1bio0 bits determine how the tm output pin changes state when a certain compare match condition occurs. the pwm output function is modified by changing these two bits. it is necessary to change the values of the t1bio1 and t1bio0 bits only after the tm has been switched off. unpredictable pwm outputs will occur if the t1bio1 and t1bio0 bits are changed when the tm is running rev. 1.10 93 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
bit 3 t1boc : tp1b_0, tp1b_1, tp1b_2 output control bit compare match output mode 0: initial low 1: initial high mode/ single pulse output mode 0: active low 1: active high this is the output control bit for the tm output pin. its operation depends upon whether tm is being used in the compare match output mode or in the pwm mode/ single pulse output mode. it has no effect if the tm is in the timer/counter mode. in the compare match output mode it determines the logic level of the tm output pin before a compare match occurs. in the pwm mode it determines if the pwm signal is active high or active low. bit 2 t1bpol : tp1b_0, tp1b_1, tb1b_2 output polarity control 0: non-invert 1: invert this bit controls the polarity of the tp1b_0, tp1b_1, tp1b_2 output pin. when the bit is set high the tm output pin will be inverted and not inverted when the bit is zero. it has no effect if the tm is in the timer/counter mode. bit 1~0 t1pwm1~t1pwm0 : select pwm mode 00: edge aligned 01: centre aligned, compare match on count up 10: centre aligned, compare match on count down 11: centre aligned, compare match on count up or down tm1dl register bit76543210 name d7 d6 d5 d4 d3 d2 d1 d0 r/wrrrrrrrr por00000000 bit 7~0 tm1dl : tm1 counter low byte register bit 7~bit 0 tm1 10-bit counter bit 7~bit 0 tm1dh register bit76543210 name  d9 d8 r/w  rr por  00 bit 7~2 unimplemented, read as 0 bit 1~0 tm1dh : tm1 counter high byte register bit 1~bit 0 tm1 10-bit counter bit 9~bit 8 tm1al register bit76543210 name d7 d6 d5 d4 d3 d2 d1 d0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por00000000 bit 7~0 tm1al : tm1 ccra low byte register bit 7~bit 0 tm1 10-bit ccra bit 7~bit 0 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 94 february 9, 2011
tm1ah register bit76543210 name  d9 d8 r/w  r/w r/w por  00 bit 7~2 unimplemented, read as 0 bit 1~0 tm1ah : tm1 ccra high byte register bit 1~bit 0 tm1 10-bit ccra bit 9~bit 8 tm1bl register bit76543210 name d7 d6 d5 d4 d3 d2 d1 d0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por00000000 bit7~0 tm1bl : tm1 ccrb low byte register bit 7~bit 0 tm1 10-bit ccrb bit 7~bit 0 tm1bh register bit76543210 name  d9 d8 r/w  r/w r/w por  00 bit 7~2 unimplemented, read as 0 bit 1~0 tm1bh : tm1 ccrb high byte register bit 1~bit 0 tm1 10-bit ccrb bit 9 ~ bit 8 enhanced type tm operating modes the enhanced type tm can operate in one of five operating modes, compare match output mode, pwm output mode, single pulse output mode, capture input mode or timer/counter mode. the operating mode is selected using the tnam1 and tnam0 bits in the tmnc1, and the tnbm1 and tnbm0 bits in the tmnc2 register. etm operating mode ccra compare match output mode ccra timer/count er mode ccra pwm output mode ccra single pulse output mode ccra input capture mode ccrb compare match output mode   ccrb timer/counter mode    ccrb pwm output mode  ccrb single pulse output mode  ccrb input capture mode    : permitted;  : not permitted rev. 1.10 95 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
compare output mode to select this mode, bits tnam1, tnam0 and tnbm1, tnbm0 in the tmnc1/tmnc2 registers should be all cleared to zero. in this mode once the counter is enabled and running it can be cleared by three methods. these are a counter overflow, a compare match from comparator a and a compare match from comparator p. when the tncclr bit is low, there are two ways in which the counter can be cleared. one is when a compare match occurs from comparator p, the other is when the ccrp bits are all zero which allows the counter to overflow. here both the tnaf and tnpf interrupt request flags for comparator a and comparator p respectively, will both be generated. if the tncclr bit in the tmnc1 register is high then the counter will be cleared when a compare match occurs from comparator a. however, here only the tnaf interrupt request flag will be generated even if the value of the ccrp bits is less than that of the ccra registers. therefore when tncclr is high no tnpf interrupt request flag will be generated. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 96 february 9, 2011 counter value 0x3ff ccrp ccra tnon tnpau tnapol ccrp int. flag tnpf ccra int. flag tnaf tpna o/p pin time ccrp=0 ccrp > 0 counter overflow ccrp > 0 counter cleared by ccrp value pause resume stop counter restart tncclr = 0; tnam [1:0] = 00 output pin set to initial level low if tnaoc=0 output toggle with tnaf flag note tnaio [1:0] = 10 active high output select here tnaio [1:0] = 11 toggle output select output not affected by tnaf flag. remains high until reset by tnon bit output pin reset to initial value output controlled by other pin-shared function output inverts when tnapol is high etm ccra compare match output mode -- tncclr = 0 note: 1. with tncclr=0 a comparator p match will clear the counter 2. the tpna output pin is controlled only by the tnaf flag 3. the output pin is reset to its initial state by a tnon bit rising edge
as the name of the mode suggests, after a comparison is made, the tm output pin, will change state. the tm output pin condition however only changes state when a tnaf or tnbf interrupt request flag is generated after a compare match occurs from comparator a or comparator b. the tnpf interrupt request flag, generated from a compare match from comparator p, will have no effect on the tm output pin. the way in which the tm output pin changes state is determined by the condition of the tnaio1 and tnaio0 bits in the tmnc1 register for etm ccra, and the tnbio1 and tnbio0 bits in the tmnc2 register for etm ccrb. the tm output pin can be selected using the tnaio1, tnaio0 bits (for the tpna pin) and tnbio1, tnbio0 bits (for the tpnb_0, tpnb_1 or tpnb_2 pins) to go high, to go low or to toggle from its present condition when a compare match occurs from comparator a or a compare match occurs from comparator b. the initial condition of the tm output pin, which is setup after the tnon bit changes from low to high, is setup using the tnaoc or tnboc bit for tpna or tpnb_0, tpnb_1, tpnb_2 output pins. note that if the tnaio1, tnaio0 and tnbio1, tnbio0 bits are zero then no pin change will take place. rev. 1.10 97 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu counter value 0x3ff ccrp ccrb tnon tnpau tnbpol ccrp int. flag tnpf ccrb int. flag tnbf tpnb o/p pin time ccrp=0 ccrp > 0 counter overflow ccrp > 0 counter cleared by ccrp value pause resume stop counter restart tncclr = 0; tnbm [1:0] = 00 output pin set to initial level low if tnboc=0 output toggle with tnbf flag note tnbio [1:0] = 10 active high output select here tnbio [1:0] = 11 toggle output select output not affected by tnbf flag. remains high until reset by tnon bit output pin reset to initial value output controlled by other pin-shared function output inverts when tnbpol is high etm ccrb compare match output mode -- tncclr = 0 note: 1. with tncclr=0 a comparator p match will clear the counter 2. the tpnb output pin is controlled only by the tnbf flag 3. the output pin is reset to its initial state by a tnon bit rising edge
as the name of the mode suggests, after a comparison is made, the tm output pin, will change state. the tm output pin condition however only changes state when an tnaf or tnbf interrupt request flag is generated after a compare match occurs from comparator a or comparator b. the tnpf interrupt request flag, generated from a compare match from comparator p, will have no effect on the tm output pin. the way in which the tm output pin changes state is determined by the condition of the tnaio1 and tnaio0 bits in the tmnc1 register for etm ccra, and the tnbio1 and tnbio0 bits in the tmnc2 register for etm ccrb. the tm output pin can be selected using the tnaio1, tnaio0 bits (for the tpna pin) and tnbio1, tnbio0 bits (for the tpnb_0, tpnb_1 or tpnb_2 pins) to go high, to go low or to toggle from its present condition when a compare match occurs from comparator a or a compare match occurs from comparator b. the initial condition of the tm output pin, which is setup after the tnon bit changes from low to high, is setup using the tnaoc or tnboc bit for tpna or tpnb_0, tpnb_1, tpnb_2 output pins. note that if the tnaio1,tnaio0 and tnbio1, tnbio0 bits are zero then no pin change will take place. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 98 february 9, 2011 counter value 0x3ff ccrp ccra tnon tnpau tnapol ccrp int. flag tnpf ccra int. flag tnaf tpna o/p pin time ccra=0 ccra = 0 counter overflow ccra > 0 counter cleared by ccra value pause resume stop counter restart tncclr = 1; tnam [1:0] = 00 output pin set to initial level low if tnaoc=0 output toggle with tnaf flag note tnaio [1:0] = 10 active high output select here tnaio [1:0] = 11 toggle output select output not affected by tnaf flag. remains high until reset by tnon bit output pin reset to initial value output controlled by other pin-shared function output inverts when tnapol is high tnpf not generated no tnaf flag generated on ccra overflow output does not change etm ccra compare match output mode -- tncclr = 1 note: 1. with tncclr=1 a comparator a match will clear the counter 2. the tpna output pin is controlled only by the tnaf flag 3. the tpna output pin is reset to its initial state by a tnon bit rising edge 4. the tnpf flag is not generated when tncclr=1
timer/counter mode to select this mode, bits tnam1, tnam0 and tnbm1, tnbm0 in the tmnc1 and tmnc2 register should all be set high. the timer/counter mode operates in an identical way to the compare match output mode generating the same interrupt flags. the exception is that in the timer/counter mode the tm output pin is not used. therefore the above description and timing diagrams for the compare match output mode can be used to understand its function. as the tm output pin is not used in this mode, the pin can be used as a normal i/o pin or other pin-shared function. pwm output mode to select this mode, the required bit pairs, tnam1, tnam0 and tnbm1, tnbm0 should be set to 10 respectively and also the tnaio1, tnaio0 and tnbio1, tnbio0 bits should be set to 10 respectively. the pwm function within the tm is useful for applications which require functions such as motor control, heating control, illumination control etc. by providing a signal of fixed frequency but of varying duty cycle on the tm output pin, a square wave ac waveform can be generated with varying equivalent dc rms values. as both the period and duty cycle of the pwm waveform can be controlled, the choice of generated waveform is extremely flexible. in the pwm mode, the tncclr bit is used to determine in which way the pwm period is controlled. with the tncclr bit set high, the pwm period can be finely controlled using the ccra registers. in this case the ccrb registers are used to set the pwm duty value (for tpnb output pins). the ccrp bits are not used and tpna output pin is not used. the pwm output can rev. 1.10 99 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu counter value 0x3ff ccrb ccra tnon tnpau tnbpol ccrb int. flag tnbf ccra int. flag tnaf tpnb o/p pin time ccra=0 ccra = 0 counter overflow ccra > 0 counter cleared by ccra value pause resume stop counter restart tncclr = 1; tnbm [1:0] = 00 output pin set to initial level low if tnboc=0 output toggle with tnbf flag note tnbio [1:0] = 10 active high output select here tnbio [1:0] = 11 toggle output select output not affected by tnbf flag. remains high until reset by tnon bit output pin reset to initial value output controlled by other pin-shared function output inverts when tnbpol is high no tnaf flag generated on ccra overflow etm ccrb compare match output mode -- tncclr = 1 note: 1. with tncclr=1 a comparator a match will clear the counter 2. the tpnb output pin is controlled only by the tnbf flag 3. the tpnb output pin is reset to its initial state by a tnon bit rising edge 4. the tnpf flag is not generated when tncclr=1
only be generated on the tpnb output pins. with the tncclr bit cleared to zero, the pwm period is set using one of the eight values of the three ccrp bits, in multiples of 128. now both ccra and ccrb registers can be used to setup different duty cycle values to provide dual pwm outputs on their relative tpna and tpnb pins. the tnpwm1 and tnpwm0 bits determine the pwm alignment type, which can be either edge or centre type. in edge alignment, the leading edge of the pwm signals will all be generated concurrently when the counter is reset to zero. with all power currents switching on at the same time, this may give rise to problems in higher power applications. in centre alignment the centre of the pwm active signals will occur sequentially, thus reducing the level of simultaneous power switching currents. interrupt flags, one for each of the ccra, ccrb and ccrp, will be generated when a compare match occurs from either the comparator a, comparator b or comparator p. the tnaoc and tnboc bits in the tmnc1 and tmnc2 register are used to select the required polarity of the pwm waveform while the two tnaio1, tnaio0 and tnbio1, tnbio0 bits pairs are used to enable the pwm output or to force the tm output pin to a fixed high or low level. the tnapol and tnbpol bit are used to reverse the polarity of the pwm output waveform.  etm, pwm mode, edge-aligned mode, tncclr=0 ccrp 001b 010b 011b 100b 101b 110b 111b 000b period 128 256 384 512 640 768 896 1024 a duty ccra b duty ccrb if f sys = 16mhz, tm clock source select f sys /4, ccrp = 100b, ccra = 128 and ccrb = 256, the tp1a pwm output frequency = (f sys /4)/512=f sys /2048 = 7.8125khz, duty = 128/512 = 25%. the tp1b_n pwm output frequency = (f sys /4)/512=f sys /2048 = 7.8125khz, duty = 256/512 = 50%. if the duty value defined by ccra or ccrb register is equal to or greater than the period value, then the pwm output duty is 100%.  etm, pwm mode, edge-aligned mode, tncclr=1 ccra 1 2 3 511 512 1021 1022 1023 period 1 2 3 511 512 1021 1022 1023 b duty ccrb  etm, pwm mode, center-aligned mode, tncclr=0 ccrp 001b 010b 011b 100b 101b 110b 111b 000b period 256 512 768 1024 1280 1536 1792 2046 a duty (ccra 2)1 b duty (ccrb 2)1  etm, pwm mode, center-aligned mode, tncclr=1 ccra 1 2 3 511 512 1021 1022 1023 period 2 4 6 1022 1024 2042 2044 2046 b duty (ccrb 2)1 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 100 february 9, 2011
rev. 1.10 101 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu counter value ccrp ccra tnon tnpau tnapol ccra int. flag tnaf ccrb int. flag tnbf tpna pin (tnaoc=1) time counter cleared by ccrp pause resume stop counter restart tncclr = 0; tnam [1:0] = 10, tnbm [1:0] = 10; tnpwm [1:0] = 00 output pin reset to initial value output controlled by other pin-shared function output inverts when tnapol is high ccrb ccrp int. flag tnpf tpnb pin (tnboc=1) tpnb pin (tnboc=0) duty cycle set by ccra duty cycle set by ccrb pwm period set by ccrp duty cycle set by ccra duty cycle set by ccra etm pwm mode -- edge aligned note: 1. here tncclr=0 therefore ccrp clears counter and determines the pwm period 2. the internal pwm function continues running even when tnaio [1:0] (or tnbio [1:0]) = 00 or 01 3. ccra controls the tpna pwm duty and ccrb controls the tpnb pwm duty
ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 102 february 9, 2011 counter value ccra tnon tnpau tnbpol ccrb int. flag tnbf time counter cleared by ccra pause resume stop counter restart tncclr = 1; tnbm [1:0] = 10; tnpwm [1:0] = 00 output pin reset to initial value output controlled by other pin-shared function output inverts when tnbpol is high ccrb ccrp int. flag tnpf tpnb pin (tnboc=1) tpnb pin (tnboc=0) duty cycle set by ccrb pwm period set by ccra etm pwm mode -- edge aligned note: 1. here tncclr=1 therefore ccra clears the counter and determines the pwm period 2. the internal pwm function continues running even when tnbio [1:0] = 00 or 01 3. the ccra controls the tpnb pwm period and ccrb controls the tpnb pwm duty 4. here the tm pin control register should not enable the tpna pin as a tm output pin.
rev. 1.10 103 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu counter value ccrp ccra tnon tnpau tnapol ccra int. flag tnaf ccrb int. flag tnbf tpna pin (tnaoc=1) time pause resume stop counter restart tncclr = 0; tnam [1:0] = 10, tnbm [1:0] = 10; tnpwm [1:0] = 11 output pin reset to initial value output controlled by other pin-shared function output inverts when tnapol is high ccrb ccrp int. flag tnpf tpnb pin (tnboc=1) tpnb pin (tnboc=0) duty cycle set by ccra duty cycle set by ccrb pwm period set by ccrp etm pwm mode -- centre aligned note: 1. here tncclr=0 therefore ccrp clears the counter and determines the pwm period 2. tnpwm [1:0] =11 therefore the pwm is centre aligned 3. the internal pwm function continues running even when tnaio [1:0] (or tnbio [1:0]) = 00 or 01 4. ccra controls the tpna pwm duty and ccrb controls the tpnb pwm duty 5. ccrp will generate an interrupt request when the counter decrements to its zero value
single pulse output mode to select this mode, the required bit pairs, tnam1, tnam0 and tnbm1, tnbm0 should be set to 10 respectively and also the corresponding tnaio1, tnaio0 and tnbio1, tnbio0 bits should be set to 11 respectively. the single pulse output mode, as the name suggests, will generate a single shot pulse on the tm output pin. the trigger for the pulse tpna output leading edge is a low to high transition of the tnon bit, which can be implemented using the application program. the trigger for the pulse tpnb output leading edge is a compare match from comparator b, which can be implemented using the application program. however in the single pulse mode, the tnon bit can also be made to automatically change from low to high using the external tckn pin, which will in turn initiate the single pulse output of tpna. when the tnon bit transitions to a high level, the counter will start running and the pulse leading edge of tpna will be generated. the tnon bit should remain high when the pulse is in its active state. the generated pulse trailing edge of tpna and tpnb will be generated when the tnon bit is cleared to zero, which can be implemented using the application program or when a compare match occurs from comparator a. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 104 february 9, 2011 counter value ccra tnon tnpau tnbpol ccra int. flag tnaf ccrb int. flag tnbf time pause resume stop counter restart tncclr = 1; tnbm [1:0] = 10; tnpwm [1:0] = 11 output pin reset to initial value output controlled by other pin-shared function ccrb tpnb pin (tnboc=1) tpnb pin (tnboc=0) duty cycle set by ccrb pwm period set by ccra output inverts when tnbpol is high ccrp int. flag tnpf etm pwm mode -- centre aligned note: 1. here tncclr=1 therefore ccra clears the counter and determines the pwm period 2. tnpwm [1:0] =11 therefore the pwm is centre aligned 3. the internal pwm function continues running even when tnbio [1:0] = 00 or 01 4. ccra controls the tpnb pwm period and ccrb controls the tpnb pwm duty 5. ccrp will generate an interrupt request when the counter decrements to its zero value
however a compare match from comparator a will also automatically clear the tnon bit and thus generate the single pulse output trailing edge of tpna and tpnb. in this way the ccra value can be used to control the pulse width of tpna. the ccra-ccrb value can be used to control the pulse width of tpnb. a compare match from comparator a and comparator b will also generate tm interrupts. the counter can only be reset back to zero when the tnon bit changes from low to high when the counter restarts. in the single pulse mode ccrp is not used. the tncclr bit is also not used. rev. 1.10 105 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu single pulse generation
ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 106 february 9, 2011 counter value ccrb ccra tnon tnpau tnapol ccrb int. flag tnbf ccra int. flag tnaf tpna pin (tnaoc=1) time counter stopped by ccra pause resume counter stops by software counter reset when tnon returns high tnam [1:0] = 10, tnbm [1:0] = 10; tnaio [1:0] = 11, tnbio [1:0] = 11 pulse width set by (ccra-ccrb) output inverts when tnbpol=1 tckn pin software trigger cleared by ccra match tckn pin trigger auto. set by tckn pin software trigger software clear software trigger software trigger tnbpol tpna pin (tnaoc=0) tpnb pin (tnboc=1) tpnb pin (tnboc=0) pulse width set by ccra output inverts when tnapol=1 single pulse mode note: 1. counter stopped by ccra 2. ccrp is not used 3. the pulse is triggered by the tckn pin or by setting the tnon bit high 4. a tckn pin active edge will automatically set the tnon bit high 5. in the single pulse mode, tnaio [1:0] and tnbio [1:0] must be set to 11  and can not be changed.
capture input mode to select this mode bits tnam1, tnam0 and tnbm1, tnbm0 in the tmnc1 and tmnc2 registers should be set to 01 respectively. this mode enables external signals to capture and store the present value of the internal counter and can therefore be used for applications such as pulse width measurements. the external signal is supplied on the tpna and tpnb_0, tpnb_1, tpnb_2 pins, whose active edge can be either a rising edge, a falling edge or both rising and falling edges; the active edge transition type is selected using the tnaio1, tnaio0 and tnbio1, tnbio0 bits in the tmnc1 and tmnc2 registers. the counter is started when the tnon bit changes from low to high which is initiated using the application program. when the required edge transition appears on the tpna and tpnb_0, tpnb_1, tpnb_2 pins the present value in the counter will be latched into the ccra and ccrb registers and a tm interrupt generated. irrespective of what events occur on the tpna and tpnb_0, tpnb_1, tpnb_2 pins the counter will continue to free run until the tnon bit changes from high to low. when a ccrp compare match occurs the counter will reset back to zero; in this way the ccrp value can be used to control the maximum counter value. when a ccrp compare match occurs from comparator p, a tm interrupt will also be generated. counting the number of overflow interrupt signals from the ccrp can be a useful method in measuring long pulse widths. the tnaio1, tnaio0 and tnbio1, tnbio0 bits can select the active trigger edge on the tpna and tpnb_0, tpnb_1, tpnb_2 pins to be a rising edge, falling edge or both edge types. if the tnaio1, tnaio0 and tnbio1, tnbio0 bits are both set high, then no capture operation will take place irrespective of what happens on the tpna and tpnb_0, tpnb_1, tpnb_2 pins, however it must be noted that the counter will continue to run. rev. 1.10 107 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu counter value yy ccrp tnon tnpau ccrp int. flag tnpf ccra int. flag tnaf ccra value time counter cleared by ccrp pause resume counter reset tnam [1:0] = 01 tm capture pin tpna xx counter stop tnaio [1:0] value xx yy xx yy active edge active edge active edge 00 rising edge 01 fallin g edge 10 both edges 11 disable capture etm ccra capture input mode note: 1. tnam [1:0] = 01 and active edge set by the tnaio [1:0] bits 2. the tm capture input pin active edge transfers he counter value to ccra 3. tncclr bit not used 4. no output function -- tnaoc and tnapol bits not used 5. ccrp determines the counter value and the counter has a maximum count value when ccrp is equal to zero.
as the tpna and tpnb_0, tpnb_1, tpnb_2 pins are pin shared with other functions, care must be taken if the tm is in the capture input mode. this is because if the pin is setup as an output, then any transitions on this pin may cause an input capture operation to be executed. the tncclr, tnaoc, tnboc, tnapol and tnbpol bits are not used in this mode. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 108 february 9, 2011 counter value yy ccrp tnon tnpau ccrp int. flag tnpf ccrb int. flag tnbf ccrb value time counter cleared by ccrp pause resume counter reset tnbm [1:0] = 01 tm capture pin tpnb_x xx counter stop tnbio [1:0] value xx yy xx yy active edge active edge active edge 00 rising edge 01 fallin g edge 10 both edges 11 disable capture etm ccrb capture input mode note: 1. tnbm [1:0] = 01 and active edge set by the tnbio [1:0] bits 2. the tm capture input pin active edge transfers the counter value to ccrb 3. tncclr bit not used 4. no output function -- tnboc and tnbpol bits not used 5. ccrp determines the counter value and the counter has a maximum count value when ccrp is equal to zero.
analog to digital converter the need to interface to real world analog signals is a common requirement for many electronic systems. however, to properly process these signals by a microcontroller, they must first be converted into digital signals by a/d converters. by integrating the a/d conversion electronic circuitry into the microcontroller, the need for external components is reduced significantly with the corresponding follow-on benefits of lower costs and reduced component space requirements. a/d overview the devices contain a multi-channel analog to digital converter which can directly interface to external analog signals, such as that from sensors or other control signals and convert these signals directly into a 12-bit digital value. the accompanying block diagram shows the overall internal structure of the a/d converter, together with its associated registers. a/d converter register description overall operation of the a/d converter is controlled using six registers. a read only register pair exists to store the adc data 12-bit value. the remaining three or four registers are control registers which setup the operating and control function of the a/d converter. register name bit 76543210 adrl(adrfs=0) d3 d2 d1 d0  adrl(adrfs=1) d7 d6 d5 d4 d3 d2 d1 d0 adrh(adrfs=0) d11 d10 d9 d8 d7 d6 d5 d4 adrh(adrfs=1)  d11 d10 d9 d8 adcr0 start eocb adoff adrfs  acs1 acs0 adcr1 acs4 v125en  vrefs  adck2 adck1 adck0 acer  ace3 ace2 ace1 ace0 a/d converter register list rev. 1.10 109 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu       

                             


 
     
               
  
       !   !  "  #   " $ $  #      $    %  &    %   '     &       ( )  *            +      " $ $ #     $ #     $ ,       -  .  & / 0 a/d converter structure
a/d converter data registers  adrl, adrh as the devices contain an internal 12-bit a/d converter, they require two data registers to store the converted value. these are a high byte register, known as adrh, and a low byte register, known as adrl. after the conversion process takes place, these registers can be directly read by the microcontroller to obtain the digitised conversion value. as only 12 bits of the 16-bit register space is utilised, the format in which the data is stored is controlled by the adrfs bit in the adcr0 register as shown in the accompanying table. d0~d11 are the a/d conversion result data bits. any unused bits will be read as zero. adrfs adrh adrl 7654321076543210 0 d11d10d9d8d7d6d5d4d3d2d1d00000 1 0000d11d10d9d8d7d6d5d4d3d2d1d0 a/d data registers a/d converter control registers  adcr0, adcr1, acer to control the function and operation of the a/d converter, three control registers known as adcr0, adcr1 and acer are provided. these 8-bit registers define functions such as the selection of which analog channel is connected to the internal a/d converter, the digitised data format, the a/d clock source as well as controlling the start function and monitoring the a/d converter end of conversion status. the acs1~acs0 bits in the adcr0 register and acs4 bit is the adcr1 register define the adc input channel number. as the device contains only one actual analog to digital converter hardware circuit, each of the individual 4 analog inputs must be routed to the converter. it is the function of the acs4 and acs1~acs0 bits to determine which analog channel input pins or internal 1.25v is actually connected to the internal a/d converter. the acer control register contains the acer3~acer0 bits which determine which pins on pa0~pa3 are used as analog inputs for the a/d converter input and which pins are not to be used as the a/d converter input. setting the corresponding bit high will select the a/d input function, clearing the bit to zero will select either the i/o or other pin-shared function. when the pin is selected to be an a/d input, its original function whether it is an i/o or other pin-shared function will be removed. in addition, any internal pull-high resistors connected to these pins will be automatically removed if the pin is selected to be an a/d input. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 110 february 9, 2011
adcr0 register b i t76543210 name start eocb adoff adrfs  acs1 acs0 r/w r/w r r/w r/w  r/w r/w por0110  00 bit 7 start : start the a/d conversion 01 0 : start 0 1 : reset the a/d converter and set eocb to 1 this bit is used to initiate an a/d conversion process. the bit is normally low but if set high and then cleared low again, the a/d converter will initiate a conversion process. when the bit is set high the a/d converter will be reset. bit 6 eocb : end of a/d conversion flag 0: a/d conversion ended 1: a/d conversion in progress this read only flag is used to indicate when an a/d conversion process has completed. when the conversion process is running the bit will be high. bit 5 adoff : adc module power on/off control bit 0: adc module power on 1: adc module power off this bit controls the power to the a/d internal function. this bit should be cleared to zero to enable the a/d converter. if the bit is set high then the a/d converter will be switched off reducing the device power consumption. as the a/d converter will consume a limited amount of power, even when not executing a conversion, this may be an important consideration in power sensitive battery powered applications. note: 1. it is recommended to set adoff=1 before entering idle/sleep mode for saving power. 2. adoff=1 will power down the adc module. bit 4 adrfs : adc data format control 0: adc data msb is adrh bit 7, lsb is adrl bit 4 1: adc data msb is adrh bit 3, lsb is adrl bit 0 this bit controls the format of the 12-bit converted a/d value in the two a/d data registers. details are provided in the a/d data register section. bit 3~2 unimplemented, read as 0 bit 1~0 acs1, acs0 : select a/d channel (when acs4 is 0) 00: an0 01: an1 10: an2 11: an3 rev. 1.10 111 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
adcr1 register b i t76543210 name acs4 v125en  vrefs  adck2 adck1 adck0 r/w r/w r/w  r/w  r/w r/w r/w por 0 0  0  000 bit 7 acs4 : selecte internal 1.25v as adc input control 0: disable 1: enable this bit enables 1.25v to be connected to the a/d converter. the v125en bit must first have been set to enable the bandgap circuit 1.25v voltage to be used by the a/d converter. when the acs4 bit is set high, the bandgap 1.25v voltage will be routed to the a/d converter and the other a/d input channels disconnected. bit 6 v125en : internal 1.25v control 0: disable 1: enable this bit controls the internal bandgap circuit on/off function to the a/d converter. when the bit is set high the bandgap voltage 1.25v can be used by the a/d converter. if 1.25v is not used by the a/d converter and the lvr/lvd function is disabled then the bandgap reference circuit will be automatically switched off to conserve power. when 1.25v is switched on for use by the a/d converter, a time t bg should be allowed for the bandgap circuit to stabilise before implementing an a/d conversion. bit 5 unimplemented, read as 0 bit 4 vrefs : selecte adc reference voltage 0: internal adc power 1: vref pin this bit is used to select the reference voltage for the a/d converter. if the bit is high, then the a/d converter reference voltage is supplied on the external vref pin. if the pin is low, then the internal reference is used which is taken from the power supply pin vdd. bit 3 unimplemented, read as 0 bit 2~0 adck2, adck1, adck0 : select adc clock source 000: f sys 001: f sys /2 010: f sys /4 011: f sys /8 100: f sys /16 101: f sys /32 110: f sys /64 111: undefined these three bits are used to select the clock source for the a/d converter. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 112 february 9, 2011
acerl register b i t76543210 name  ace3 ace2 ace1 ace0 r/w  r/w r/w r/w r/w por  1111 bit 7~4 unimplemented, read as 0 bit 3 ace3 : define pa3 is a/d input or not 0: not a/d input 1: a/d input, an3 bit 2 ace2 : define pa2 is a/d input or not 0: not a/d input 1: a/d input, an2 bit 1 ace1 : define pa1 is a/d input or not 0: not a/d input 1: a/d input, an1 bit 0 ace0 : define pa0 is a/d input or not 0: not a/d input 1: a/d input, an0 a/d operation the start bit in the adcr0 register is used to start and reset the a/d converter. when the microcontroller sets this bit from low to high and then low again, an analog to digital conversion cycle will be initiated. when the start bit is brought from low to high but not low again, the eocb bit in the adcr0 register will be set high and the analog to digital converter will be reset. it is the start bit that is used to control the overall start operation of the internal analog to digital converter. the eocb bit in the adcr0 register is used to indicate when the analog to digital conversion process is complete. this bit will be automatically set to 0 by the microcontroller after a conversion cycle has ended. in addition, the corresponding a/d interrupt request flag will be set in the interrupt control register, and if the interrupts are enabled, an appropriate internal interrupt signal will be generated. this a/d internal interrupt signal will direct the program flow to the associated a/d internal interrupt address for processing. if the a/d internal interrupt is disabled, the microcontroller can be used to poll the eocb bit in the adcr0 register to check whether it has been cleared as an alternative method of detecting the end of an a/d conversion cycle. the clock source for the a/d converter, which originates from the system clock f sys , can be chosen to be either f sys or a subdivided version of f sys . the division ratio value is determined by the adck2~adck0 bits in the adcr1 register. although the a/d clock source is determined by the system clock f sys , and by bits adck2~adck0, there are some limitations on the maximum a/d clock source speed that can be selected. as the minimum value of permissible a/d clock period, t adck ,is0.5  s, care must be taken for system clock frequencies equal to or greater than 4mhz. for example, if the system clock operates at a frequency of 4mhz, the adck2~adck0 bits should not be set to 000b. doing so will give a/d clock periods that are less than the minimum a/d clock period which may result in inaccurate a/d conversion values. refer to the following table for examples, where values marked with an asterisk * show where, depending upon the device, special care must be taken, as the values may be less than the specified minimum a/d clock period. rev. 1.10 113 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
f sys a/d clock period (t adck ) adck2, adck1, adck0 = 000 (f sys ) adck2, adck1, adck0 = 001 (f sys /2) adck2, adck1, adck0 = 010 (f sys /4) adck2, adck1, adck0 =011 (f sys /8) adck2, adck1, adck0 = 100 (f sys /16) adck2, adck1, adck0 = 101 (f sys /32) adck2, adck1, adck0 =110 (f sys /64) adck2, adck1, adck0 = 111 1mhz 1s2 s4 s8  s16  s32  s64 s undefined 2mhz 500ns 1s2 s4 s8  s16  s32 s undefined 4mhz 250ns* 500ns 1s2 s4 s8  s16 s undefined 8mhz 125ns* 250ns* 500ns 1s2 s4 s8 s undefined 12mhz 83ns* 167ns* 333ns* 667ns 1.33 s 2.67 s 5.33s undefined a/d clock period examples controlling the power on/off function of the a/d converter circuitry is implemented using the adoff bit in the adcr0 register. this bit must be zero to power on the a/d converter. when the adoff bit is cleared to zero to power on the a/d converter internal circuitry a certain delay, as indicated in the timing diagram, must be allowed before an a/d conversion is initiated. even if no pins are selected for use as a/d inputs by clearing the ace3~ace0 bits in the acer register, if the adoff bit is zero then some power will still be consumed. in power conscious applications it is therefore recommended that the adoff is set high to reduce power consumption when the a/d converter function is not being used. the reference voltage supply to the a/d converter can be supplied from either the positive power supply pin, vdd, or from an external reference sources supplied on pin vref. the desired selection is made using the vrefs bit. as the vref pin is pin-shared with other functions, when the vrefs bit is set high, the vref pin function will be selected and the other pin functions will be disabled automatically. a/d input pins all of the a/d analog input pins are pin-shared with the i/o pins on pa3~pa0 as well as other functions. the ace3~ ace0 bits in the acer register determines whether the input pins are setup as a/d converter analog inputs or whether they have other functions. if the ace3~ ace0 bits for its corresponding pin is set high then the pin will be setup to be an a/d converter input and the original pin functions disabled. in this way, pins can be changed under program control to change their function between a/d inputs and other functions. all pull-high resistors, which are setup through register programming, will be automatically disconnected if the pins are setup as a/d inputs. note that it is not necessary to first setup the a/d pin as an input in the pac port control register to enable the a/d input as when the ace3~ ace0 bits enable an a/d input, the status of the port control register will be overridden. the a/d converter has its own reference voltage pin vref however the reference voltage can also be supplied from the power supply pin, a choice which is made through the vrefs bit in the adcr1 register. the analog input values must not be allowed to exceed the value of vref. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 114 february 9, 2011              *          # 1  
#      $       $    $   2 ,      #   3   4 


 
    
5  4 1      
  ( )     )     a/d input structure
summary of a/d conversion steps the following summarises the individual steps that should be executed in order to implement an a/d conversion process.  step 1 select the required a/d conversion clock by correctly programming bits adck2~adck0 in the adcr1 register.  step 2 enable the a/d by clearing the adoff bit in the adcr0 register to zero.  step 3 select which channel is to be connected to the internal a/d converter by correctly programming the acs4 and acs1~acs0 bits which are also contained in the adcr1 and adcr0 registers.  step 4 select which pins are to be used as a/d inputs and configure them by correctly programming the ace11~ace0 bits in the acerh and acerl registers.  step 5 if the interrupts are to be used, the interrupt control registers must be correctly configured to ensure the a/d converter interrupt function is active. the master interrupt control bit, emi, and the a/d converter interrupt bit, ade, must both be set to high to do this.  step 6 the analog to digital conversion process can now be initialised by setting the start bit in the adcr0 register from low to high and then to low again. note that this bit should have been originally cleared to 0.  step 7 to check when the analog to digital conversion process is complete, the eocb bit in the adcr0 register can be polled. the conversion process is complete when this bit goes low. when this occurs, the a/d data registers adrl and adrh can be read to obtain the conversion value. as an alternative method if the interrupts are enabled and the stack is not full, the program can wait for an a/d interrupt to occur. note: when checking for the end of the conversion process, if the method of polling the eocb bit in the adcr register is used, the interrupt enable step above can be omitted. rev. 1.10 115 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
the accompanying diagram shows graphically the various stages involved in an analog to digital conversion process and its associated timing. after an a/d conversion process has been initiated by the application program, the microcontroller internal hardware will begin to carry out the conversion, during which time the program can continue with other functions. the time taken for the a/d conversion is 16 t adck where t adck is equal to the a/d clock period. programming considerations during microcontroller operates where the a/d converter is not being used, the a/d internal circuitry can be switched off to reduce power consumption, by setting bit adoff high in the adcr0 register. when this happens, the internal a/d converter circuits will not consume power irrespective of what analog voltage is applied to their input lines. if the a/d converter input lines are used as normal i/os, then care must be taken as if the input voltage is not at a valid logic level, then this may lead to some increase in power consumption. a/d transfer function as the devices contain a 12-bit a/d converter, its full-scale converted digitised value is equal to fffh. since the full-scale analog input value is equal to the v dd or v ref voltage, this gives a single bit analog input value of v dd or v ref divided by 4096. 1 lsb= (v dd or v ref )  4096 the a/d converter input voltage value can be calculated using the following equation: a/d input voltage = a/d output digital value  (v dd or v ref )  4096 the diagram shows the ideal transfer function between the analog input value and the digitised output value for the a/d converter. except for the digitised zero value, the subsequent digitised values will change at a point 0.5 lsb below where they would change without the offset, and the last full scale digitised value will change at a point 1.5 lsb below the v dd or v ref level. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 116 february 9, 2011          
      6
   #    # !   !  "  #   ( )    )      7
2   

  3          
     8  
  
 4         1      8 

          9   
           
    

      

      6 4       6
        #           
    

      

   #           
    

      

  3          
          6 4       6
            "   !          
      6
     " $ $     :  3 1 
"  a/d conversion timing
a/d programming example the following two programming examples illustrate how to setup and implement an a/d conversion. in the first example, the method of polling the eocb bit in the adcr0 register is used to detect when the conversion cycle is complete, whereas in the second example, the a/d interrupt is used to determine when the conversion is complete. example 1: using an eocb polling method to detect the end of conversion clr ade ; disable adc interrupt mov a,03h mov adcr1,a ; select f sys /8 as a/d clock and switch off 1.25v clr adoff mov a,0fh ; setup acer register to configure pins an0~an3 mov acer,a mov a,00h mov adcr0,a ; enable and connect an0 channel to a/d converter : start_conversion: clr start ; high pulse on start bit to initiate conversion set start ; reset a/d clr start ; start a/d polling_eoc: sz eocb ; poll the adcr0 register eocb bit to detect end of a/d conversion jmp polling_eoc ; continue polling mov a,adrl ; read low byte conversion result value mov adrl_buffer,a ; save result to user defined register mov a,adrh ; read high byte conversion result value mov adrh_buffer,a ; save result to user defined register : jmp start_conversion ; start next a/d conversion rev. 1.10 117 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu $ $   -                     0       
    
 1  $ $ $  $ $             *    #     (  ;  (  ; ( (  ;  (  ; /        5  4 1      
 *    #          $ (  ; / ideal a/d transfer function
example 2: using the interrupt method to detect the end of conversion clr ade ; disable adc interrupt mov a,03h mov adcr1,a ; select fsys/8 as a/d clock and switch off 1.25v clr adoff mov a,0fh ; setup acer register to configure pins an0~an3 mov acer,a mov a,00h mov adcr0,a ; enable and connect an0 channel to a/d converter start_conversion: clr start ; high pulse on start bit to initiate conversion set start ; reset a/d clr start ; start a/d clr adf ; clear adc interrupt request flag set ade ; enable adc interrupt set emi ; enable global interrupt : ; adc interrupt service routine adc_isr: mov acc_stack,a ; save acc to user defined memory mov a,status mov status_stack,a ; save status to user defined memory : mov a,adrl ; read low byte conversion result value mov adrl_buffer,a ; save result to user defined register mov a,adrh ; read high byte conversion result value mov adrh_buffer,a ; save result to user defined register : exit_int_isr: mov a,status_stack mov status,a ; restore status from user defined memory mov a,acc_stack ; restore acc from user defined memory reti ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 118 february 9, 2011
interrupts interrupts are an important part of any microcontroller system. when an external event or an internal function such as a timer module or an a/d converter requires microcontroller attention, their corresponding interrupt will enforce a temporary suspension of the main program allowing the microcontroller to direct attention to their respective needs. the device contains several external interrupt and internal interrupts functions. the external interrupts are generated by the action of the external int0 and int1 pins while the internal interrupts are generated by various internal functions such as the tms, time base, lvd and the a/d converter. interrupt registers overall interrupt control, which basically means the setting of request flags when certain microcontroller conditions occur and the setting of interrupt enable bits by the application program, is controlled by a series of registers, located in the special purpose data memory, as shown in the accompanying table. the number of registers depends upon the device chosen but fall into three categories. the first is the intc0~intc1 registers which setup the primary interrupts, the second is the mfi0~mfi1 registers which setup the multi-function interrupts. finally there is an integ register to setup the external interrupt trigger edge type. each register contains a number of enable bits to enable or disable individual registers as well as interrupt flags to indicate the presence of an interrupt request. the naming convention of these follows a specific pattern. first is listed an abbreviated interrupt type, then the (optional) number of that interrupt followed by either an  e  for enable/ disable bit or  f  for request flag. function enable bit request flag notes global emi  intn pin intne intnf n=0or1 multi-function mfne mfnf n=0or1 a/d converter ade adf  time base tbe tbf  lvd lve lvf  tm tnpe tnpf n=0or1 tnae tnaf tnbe tnbf n = 1 interrupt register bit naming conventions rev. 1.10 119 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
interrupt register contents  ht66f13 name bit 76543210 integ  int1s1 int1s0 int0s1 int0s0 intc0  t1pf int1f int0f t1pe int1e int0e emi intc1 lvf tbf adf t1af lve tbe ade t1ae interrupt register contents  ht66f14 name bit 76543210 integ  int1s1 int1s0 int0s1 int0s0 intc0  mf0f int1f int0f mf0e int1e int0e emi intc1 lvf tbf adf mf1f lve tbe ade mf1e mfi0  t0af t0pf  t0ae t0pe mfi1  t1af t1pf  t1ae t1pe interrupt register contents  HT66F15 name bit 76543210 integ  int1s1 int1s0 int0s1 int0s0 intc0  mf0f int1f int0f mf0e int1e int0e emi intc1 lvf tbf adf mf1f lve tbe ade mf1e mfi0  t0af t0pf  t0ae t0pe mfi1  t1bf t1af t1pf  t1be t1ae t1pe integ register  ht66f13/ht66f14/HT66F15 bit76543210 name  int1s1 int1s0 int0s1 int0s0 r/w  r/w r/w r/w r/w por  0000 bit 7~4 unimplemented, read as 0 bit 3~2 int1s1, int1s0 : interrupt edge control for int1 pin 00: disable 01: rising edge 10: falling edge 11: both rising and falling edges bit 1~0 int0s1, int0s0 : interrupt edge control for int0 pin 00: disable 01: rising edge 10: falling edge 11: both rising and falling edges ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 120 february 9, 2011
intc0 register  ht66f13 bit76543210 name  t1pf int1f int0f t1pe int1e int0e emi r/w  r/w r/w r/w r/w r/w r/w r/w por  0000000 bit 7 unimplemented, read as 0 bit 6 t1pf : tm1 comparator p match interrupt request flag 0: no request 1: interrupt request bit 5 int1f : int1 interrupt request flag 0: no request 1: interrupt request bit 4 int0f : int0 interrupt request flag 0: no request 1: interrupt request bit 3 t1pe : tm1 comparator p match interrupt control 0: disable 1: enable bit 2 int1e : int1 interrupt control 0: disable 1: enable bit 1 int0e : int0 interrupt control 0: disable 1: enable bit 0 emi : global interrupt control 0: disable 1: enable intc0 register  ht66f14/HT66F15 bit76543210 name  mf0f int1f int0f mf0e int1e int0e emi r/w  r/w r/w r/w r/w r/w r/w r/w por  0000000 bit 7 unimplemented, read as 0 bit 6 mf0f : multi-function 0 interrupt request flag 0: no request 1: interrupt request bit 5 int1f : int1 interrupt request flag 0: no request 1: interrupt request bit 4 int0f : int0 interrupt request flag 0: no request 1: interrupt request bit 3 mf0e : multi-function 0 interrupt control 0: disable 1: enable bit 2 int1e : int1 interrupt control 0: disable 1: enable bit 1 int0e : int0 interrupt control 0: disable 1: enable bit 0 emi : global interrupt control 0: disable 1: enable rev. 1.10 121 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
intc1 register  ht66f13 b i t76543210 name lvf tbf adf t1af lve tbe ade t1ae r/w r/w r/w r/w r/w r/w r/w r/w r/w por00000000 bit 7 lvf : lvd interrupt request flag 0: no request 1: interrupt request bit 6 tbf : time base interrupt request flag 0: no request 1: interrupt request bit 5 adf : a/d converter interrupt request flag 0: no request 1: interrupt request bit 4 t1af : tm1 comparator a match interrupt request flag 0: no request 1: interrupt request bit 3 lve : lvd interrupt control 0: disable 1: enable bit 2 tbe : time base interrupt control 0: disable 1: enable bit 1 ade : a/d converter interrupt control 0: disable 1: enable bit 0 t1ae : tm1 comparator a match interrupt control 0: disable 1: enable intc1 register  ht66f14/HT66F15 b i t76543210 name lvf tbf adf mf1f lve tbe ade mf1e r/w r/w r/w r/w r/w r/w r/w r/w r/w por00000000 bit 7 lvf : lvd interrupt request flag 0: no request 1: interrupt request bit 6 tbf : time base interrupt request flag 0: no request 1: interrupt request bit 5 adf : a/d converter interrupt request flag 0: no request 1: interrupt request bit 4 mf1f : multi-function 1 interrupt request flag 0: no request 1: interrupt request bit 3 lve : lvd interrupt control 0: disable 1: enable bit 2 tbe : time base interrupt control 0: disable 1: enable bit 1 ade : a/d converter interrupt control 0: disable 1: enable bit 0 mf1e : multi-function 1 interrupt control 0: disable 1: enable ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 122 february 9, 2011
mfi0 register  ht66f14/HT66F15 bit76543210 name  t0af t0pf  t0ae t0pe r/w  r/w r/w  r/w r/w por  00  00 bit 7~6 unimplemented, read as 0 bit 5 t0af : tm0 comparator a match interrupt request flag 0: no request 1: interrupt request bit 4 t0pf : tm0 comparator p match interrupt request flag 0: no request 1: interrupt request bit 3~2 unimplemented, read as 0 bit 1 t0ae : tm0 comparator a match interrupt control 0: disable 1: enable bit 0 t0pe : tm0 comparator p match interrupt control 0: disable 1: enable mfi1 register  ht66f14 bit76543210 name  t1af t1pf  t1ae t1pe r/w  r/w r/w  r/w r/w por  00  00 bit 7~6 unimplemented, read as 0 bit 5 t1af : tm1 comparator a match interrupt request flag 0: no request 1: interrupt request bit 4 t1pf : tm1 comparator p match interrupt request flag 0: no request 1: interrupt request bit 3~2 unimplemented, read as 0 bit 1 t1ae : tm1 comparator a match interrupt control 0: disable 1: enable bit 0 t1pe : tm1 comparator p match interrupt control 0: disable 1: enable rev. 1.10 123 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
mfi1 register  HT66F15 bit76543210 name  t1bf t1af t1pf  t1be t1ae t1pe r/w  r/w r/w r/w  r/w r/w r/w por  000  000 bit 7 unimplemented, read as 0 bit 6 t1bf : tm1 comparator b match interrupt request flag 0: no request 1: interrupt request bit 5 t1af : tm1 comparator a match interrupt request flag 0: no request 1: interrupt request bit 4 t1pf : tm1 comparator p match interrupt request flag 0: no request 1: interrupt request bit 3 unimplemented, read as 0 bit 2 t1be : tm1 comparator b match interrupt control 0: disable 1: enable bit 1 t1ae : tm1 comparator a match interrupt control 0: disable 1: enable bit 0 t1pe : tm1 comparator p match interrupt control 0: disable 1: enable interrupt operation when the conditions for an interrupt event occur, such as a tm comparator p, comparator a or comparator b match or a/d conversion completion, etc., the relevant interrupt request flag will be set. whether the request flag actually generates a program jump to the relevant interrupt vector is determined by the condition of the interrupt enable bit. if the enable bit is set high then the program will jump to its relevant vector; if the enable bit is zero then although the interrupt request flag is set an actual interrupt will not be generated and the program will not jump to the relevant interrupt vector. the global interrupt enable bit, if cleared to zero, will disable all interrupts. when an interrupt is generated, the program counter, which stores the address of the next instruction to be executed, will be transferred onto the stack. the program counter will then be loaded with a new address which will be the value of the corresponding interrupt vector. the microcontroller will then fetch its next instruction from this interrupt vector. the instruction at this vector will usually be a  jmp which will jump to another section of program which is known as the interrupt service routine. here is located the code to control the appropriate interrupt. the interrupt service routine must be terminated with a  reti , which retrieves the original program counter address from the stack and allows the microcontroller to continue with normal execution at the point where the interrupt occurred. the various interrupt enable bits, together with their associated request flags, are shown in the accompanying diagrams with their order of priority. some interrupt sources have their own individual vector while others share the same multi-function interrupt vector. once an interrupt subroutine is serviced, all the other interrupts will be blocked, as the global interrupt enable bit, emi bit will be cleared automatically. this will prevent any further interrupt nesting from occurring. however, if other interrupt requests occur during this interval, although the interrupt will not be immediately serviced, the request flag will still be recorded. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 124 february 9, 2011
if an interrupt requires immediate servicing while the program is already in another interrupt service routine, the emi bit should be set after entering the routine, to allow interrupt nesting. if the stack is full, the interrupt request will not be acknowledged, even if the related interrupt is enabled, until the stack pointer is decremented. if immediate service is desired, the stack must be prevented from becoming full. in case of simultaneous requests, the accompanying diagram shows the priority that is applied. all of the interrupt request flags when set will wake-up the device if it is in sleep or idle mode, however to prevent a wake-up from occurring the corresponding flag should be set before the device is in sleep or idle mode. rev. 1.10 125 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu int0 pin int1 pin int0f int1f int0e int1e emi 04h emi 08h tm1 p t1pf t1pe emi 0ch tm1 a t1af t1ae emi 10h a/d adf ade emi 14h time base tbf tbe emi 18h lvd lvf lve emi 1ch interrupt name request flags enable bits master enable vector emi auto disabled in isr low xxe enable bits xxf request flag, auto reset in isr legend priority high interrupt structure  ht66f13 int0 pin int1 pin int0f int1f int0e int1e emi 04h emi 08h m. funct. 0 mf0f mf0e emi 0ch emi 10h a/d adf ade emi 14h time base tbf tbe emi 18h lvd lvf lve emi 1ch interrupt name request flags enable bits master enable vector emiautodisabledinisr priority high low tm1 p t1pf t1pe tm1 a t1af t1ae m. funct. 1 mf1f mf1e tm0 p t0pf t0pe tm0 a t0af t0ae interrupts contained within multi-function interrupts xxe enable bits xxf request flag, auto reset in isr legend xxf request flag, no auto reset in isr interrupt structure  ht66f14
external interrupt the external interrupts are controlled by signal transitions on the pins int0~int1. an external interrupt request will take place when the external interrupt request flags, int0f~int1f, are set, which will occur when a transition, whose type is chosen by the edge select bits, appears on the external interrupt pins. to allow the program to branch to its respective interrupt vector address, the global interrupt enable bit, emi, and respective external interrupt enable bit, int0e~int1e, must first be set. additionally the correct interrupt edge type must be selected using the integ register to enable the external interrupt function and to choose the trigger edge type. as the external interrupt pins are pin-shared with i/o pins, they can only be configured as external interrupt pins if their external interrupt enable bit in the corresponding interrupt register has been set. the pin must also be setup as an input by setting the corresponding bit in the port control register. when the interrupt is enabled, the stack is not full and the correct transition type appears on the external interrupt pin, a subroutine call to the external interrupt vector, will take place. when the interrupt is serviced, the external interrupt request flags, int0f~int1f, will be automatically reset and the emi bit will be automatically cleared to disable other interrupts. note that any pull-high resistor selections on the external interrupt pins will remain valid even if the pin is used as an external interrupt input. the integ register is used to select the type of active edge that will trigger the external interrupt. a choice of either rising or falling or both edge types can be chosen to trigger an external interrupt. note that the integ register can also be used to disable the external interrupt function. multi-function interrupt within these devices there are up to six multi-function interrupts. unlike the other independent interrupts, these interrupts have no independent source, but rather are formed from other existing interrupt sources, namely the tm interrupts. a multi-function interrupt request will take place when any of the multi-function interrupt request flags, mf0f~mf1f are set. the multi-function interrupt flags will be set when any of their included functions generate an interrupt request flag. to allow the program to branch to its respective interrupt vector address, when the multi-function interrupt is enabled and the stack is not full, and either one of the interrupts contained within each of multi-function interrupt occurs, a subroutine call to one of the multi-function interrupt vectors will take place. when the interrupt is serviced, the related multi-function request flag, will be automatically reset and the emi bit will be automatically cleared to disable other interrupts. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 126 february 9, 2011 int0 pin int1 pin int0f int1f int0e int1e emi 04h emi 08h m. funct. 0 mf0f mf0e emi 0ch emi 10h a/d adf ade emi 14h time base tbf tbe emi 18h lvd lvf lve emi 1ch interrupt name request flags enable bits master enable vector emi auto disabled in isr low tm1 p t1pf t1pe tm1 a t1af t1ae m. funct. 1 mf1f mf1e tm0 p t0pf t0pe tm0 a t0af t0ae interrupts contained within multi-function interrupts tm1 b t1bf t1be priority high xxe enable bits xxf request flag, auto reset in isr legend xxf request flag, no auto reset in isr interrupt structure  HT66F15
however, it must be noted that, although the multi-function interrupt flags will be automatically reset when the interrupt is serviced, the request flags from the original source of the multi-function interrupts, namely the tm interrupts, will not be automatically reset and must be manually reset by the application program. a/d converter interrupt the a/d converter interrupt is controlled by the termination of an a/d conversion process. an a/d converter interrupt request will take place when the a/d converter interrupt request flag, adf, is set, which occurs when the a/d conversion process finishes. to allow the program to branch to its respective interrupt vector address, the global interrupt enable bit, emi, and a/d interrupt enable bit, ade, must first be set. when the interrupt is enabled, the stack is not full and the a/d conversion process has ended, a subroutine call to the a/d converter interrupt vector, will take place. when the interrupt is serviced, the a/d converter interrupt flag, adf, will be automatically cleared. the emi bit will also be automatically cleared to disable other interrupts. time base interrupts the function of the time base interrupt is to provide regular time signal in the form of an internal interrupt. it is controlled by the overflow signal from the respective timer function. when this happens, the respective interrupt request flags tbf will be set. to allow the program to branch to their respective interrupt vector addresses, the global interrupt enable bit emi and time base enable bit tbe must first be set. when the interrupt is enabled, the stack is not full and the time base overflows, a subroutine call to their respective vector locations will take place. when the interrupt is serviced, the respective interrupt request flag tbf will be automatically reset and the emi bit will be cleared to disable other interrupts. the purpose of the time base interrupt is to provide an interrupt signal at fixed time periods. their clock sources originate from the internal clock source ftb. this ftb input clock passes through a divider, the division ratio of which is selected by programming the appropriate bits in the tbc register to obtain longer interrupt periods whose value ranges. the clock source that generates ftb, which in turn controls the time base interrupt period, can originate from several different sources, as shown in the system operating mode section. rev. 1.10 127 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu : < =  '  (  ! #     3
 , >     &     ! # !  6
 #  
 5 
1 4 : < = ! #  & ! #  time base interrupt note: the f tbc is from the lirc oscillator.
tbc register bit76543210 name tbon tbck tb1 tb0  r/w r/w r/w r/w r/w  por0011  bit 7 tbon : time base control 0: disable 1: enable bit 6 tbck : time base clock f tb selection 0: f tbc 1: f sys /4 bit 5~4 tb1~tb0 : select time base time-out period 00: 4096/f tb 01: 8192/f tb 10: 16384/f tb 11: 32768/f tb bit 3~0 unimplemented, read as 0 lvd interrupt the low voltage detector interrupt is contained within the multi-function interrupt. a lvd interrupt request will take place when the lvd interrupt request flag, lvf, is set, which occurs when the low voltage detector function detects a low power supply voltage. to allow the program to branch to its respective interrupt vector address, the global interrupt enable bit, emi, low voltage interrupt enable bit, lve, and associated multi-function interrupt enable bit, must first be set. when the interrupt is enabled, the stack is not full and a low voltage condition occurs, a subroutine call to the multi-function interrupt vector, will take place. when the low voltage interrupt is serviced, the emi bit will be automatically cleared to disable other interrupts, however only the multi-function interrupt request flag will be also automatically cleared. as the lvf flag will not be automatically cleared, it has to be cleared by the application program. tm interrupts the compact and standard type tms have two interrupts each, while the enhanced type tm has three interrupts. all of the tm interrupts are contained within the multi-function interrupts in these devices except ht66f13. for each of the compact and standard type tms there are two interrupt request flags tnpf and tnaf and two enable bits tnpe and tnae. for the enhanced type tm there are three interrupt request flags tnpf, tnaf and tnbf and three enable bits tnpe, tnae and tnbe. a tm interrupt request will take place when any of the tm request flags are set, a situation which occurs when a tm comparator p, a or b match situation happens. to allow the program to branch to its respective interrupt vector address, the global interrupt enable bit, emi, respective tm interrupt enable bit, and relevant multi-function interrupt enable bit, mfne, must first be set. when the interrupt is enabled, the stack is not full and a tm comparator match situation occurs, a subroutine call to the relevant multi-function interrupt vector locations, will take place. when the tm interrupt is serviced, the emi bit will be automatically cleared to disable other interrupts, however only the related mfnf flag will be automatically cleared. as the tm interrupt request flags will not be automatically cleared, they have to be cleared by the application program. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 128 february 9, 2011
interrupt wake-up function each of the interrupt functions has the capability of waking up the microcontroller when in the sleep or idle mode. a wake-up is generated when an interrupt request flag changes from low to high and is independent of whether the interrupt is enabled or not. therefore, even though the device is in the sleep or idle mode and its system oscillator stopped, situations such as external edge transitions on the external interrupt pins, a low power supply voltage or comparator input change may cause their respective interrupt flag to be set high and consequently generate an interrupt. care must therefore be taken if spurious wake-up situations are to be avoided. if an interrupt wake-up function is to be disabled then the corresponding interrupt request flag should be set high before the device enters the sleep or idle mode. the interrupt enable bits have no effect on the interrupt wake-up function. programming considerations by disabling the relevant interrupt enable bits, a requested interrupt can be prevented from being serviced, however, once an interrupt request flag is set, it will remain in this condition in the interrupt register until the corresponding interrupt is serviced or until the request flag is cleared by the application program. where a certain interrupt is contained within a multi-function interrupt, then when the interrupt service routine is executed, as only the multi-function interrupt request flags, mf0f~mf1f, will be automatically cleared, the individual request flag for the function needs to be cleared by the application program. it is recommended that programs do not use the  call instruction within the interrupt service subroutine. interrupts often occur in an unpredictable manner or need to be serviced immediately. if only one stack is left and the interrupt is not well controlled, the original control sequence will be damaged once a call subroutine is executed in the interrupt subroutine. every interrupt has the capability of waking up the microcontroller when it is in sleep or idle mode, the wake up being generated when the interrupt request flag changes from low to high. if it is required to prevent a certain interrupt from waking up the microcontroller then its respective request flag should be first set high before enter sleep or idle mode. as only the program counter is pushed onto the stack, then when the interrupt is serviced, if the contents of the accumulator, status register or other registers are altered by the interrupt service program, their contents should be saved to the memory at the beginning of the interrupt service routine. to return from an interrupt subroutine, either a  ret or  reti instruction may be executed. the reti instruction in addition to executing a return to the main program also automatically sets the emi bit high to allow further interrupts. the ret instruction however only executes a return to the main program leaving the emi bit in its present zero state and therefore disabling the execution of further interrupts. rev. 1.10 129 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
power down mode and wake-up entering the idle or sleep mode there is only one way for the device to enter the sleep or idle mode and that is to execute the  halt  instruction in the application program. when this instruction is executed, the following will occur:  the system clock will be stopped and the application program will stop at the halt instruction.  the data memory contents and registers will maintain their present condition.  the wdt will be cleared and resume counting if the wdt clock source is selected to come from the f sub clock source and the wdt is enabled. the wdt will stop if its clock source originates from the system clock.  the i/o ports will maintain their present condition.  in the status register, the power down flag, pdf, will be set and the watchdog time-out flag, to, will be cleared. standby current considerations as the main reason for entering the sleep or idle mode is to keep the current consumption of the device to as low a value as possible, perhaps only in the order of several micro-amps, there are other considerations which must also be taken into account by the circuit designer if the power consumption is to be minimised. special attention must be made to the i/o pins on the device. all high-impedance input pins must be connected to either a fixed high or low level as any floating input pins could create internal oscillations and result in increased current consumption. this also applies to devices which have different package types, as there may be unbonbed pins. these must either be setup as outputs or if setup as inputs must have pull-high resistors connected. care must also be taken with the loads, which are connected to i/o pins, which are setup as outputs. these should be placed in a condition in which minimum current is drawn or connected only to external circuits that do not draw current, such as other cmos inputs. also note that additional standby current will also be required if the configuration options have enabled the lirc oscillator. wake-up after the system enters the sleep or idle mode, it can be woken up from one of various sources listed as follows:  an external reset  an external falling edge on port a  a system interrupt  a wdt overflow if the system is woken up by an external reset, the device will experience a full system reset, however, if the device is woken up by a wdt overflow, a watchdog timer reset will be initiated. although both of these wake-up methods will initiate a reset operation, the actual source of the wake-up can be determined by examining the to and pdf flags. the pdf flag is cleared by a system power-up or executing the clear watchdog timer instructions and is set when executing the halt instruction. the to flag is set if a wdt time-out occurs, and causes a wake-up that only resets the program counter and stack pointer, the other flags remain in their original status. each pin on port a can be setup using the pawu register to permit a negative transition on the pin to wake-up the system. when a port a pin wake-up occurs, the program will resume execution at the instruction following the  halt  instruction. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 130 february 9, 2011
if the system is woken up by an interrupt, then two possible situations may occur. the first is where the related interrupt is disabled or the interrupt is enabled but the stack is full, in which case the program will resume execution at the instruction following the halt instruction. in this situation, the interrupt which woke-up the device will not be immediately serviced, but will rather be serviced later when the related interrupt is finally enabled or when a stack level becomes free. the other situation is where the related interrupt is enabled and the stack is not full, in which case the regular interrupt response takes place. if an interrupt request flag is set high before entering the sleep or idle mode, the wake-up function of the related interrupt will be disabled. low voltage detector  lvd each device has a low voltage detector function, also known as lvd. this enabled the device to monitor the power supply voltage, v dd , and provide a warning signal should it fall below a certain level. this function may be especially useful in battery applications where the supply voltage will gradually reduce as the battery ages, as it allows an early warning battery low signal to be generated. the low voltage detector also has the capability of generating an interrupt signal. lvd register the low voltage detector function is controlled using a single register with the name lvdc. three bits in this register, vlvd2~vlvd0, are used to select one of eight fixed voltages below which a low voltage condition will be determined. a low voltage condition is indicated when the lvdo bit is set. if the lvdo bit is low, this indicates that the v dd voltage is above the preset low voltage value. the lvden bit is used to control the overall on/off function of the low voltage detector. setting the bit high will enable the low voltage detector. clearing the bit to zero will switch off the internal low voltage detector circuits. as the low voltage detector will consume a certain amount of power, it may be desirable to switch off the circuit when not in use, an important consideration in power sensitive battery powered applications. lvdc register b i t76543210 name  lvdo lvden  vlvd2 vlvd1 vlvd0 r/w  r r/w  r/w r/w r/w por  00  000 bit 7~6 unimplemented, read as 0 bit 5 lvdo : lvd output flag 0: no low voltage detect 1: low voltage detect bit lvden : low voltage detector control 0: disable 1: enable bit 3 unimplemented, read as 0 bit 2~0 vlvd2 ~ vlvd0 : select lvd voltage 000: 2.0v 001: 2.2v 010: 2.4v 011: 2.7v 100: 3.0v 101: 3.3v 110: 3.6v 111: 4.4v rev. 1.10 131 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
lvd operation the low voltage detector function operates by comparing the p ower supply voltage, v dd , with a p re-specified voltage level stored in the lvdc register. this has a range of between 2.0v and 4.4v. when the power supply voltage, v dd , falls below this pre-determined value, the lvdo bit will be s et high indicating a low power supply voltage condition. the low voltage detector function is supplied by a reference voltage which will be automatically enabled. when the device is powered down the low voltage detector will remain active if the lvden bit is high. after enabling the low voltage detector, a time delay t lvds should be allowed for the circuitry to stabilise before readi ng the lvdo bit. note also that as the v dd voltage may rise and fall rather slowly, at the voltage nears t hat of v lvd , there may be m ultiple bit lvdo transitions. the low voltage detector also has its own interrupt which is contained within one of the multi-function interrupts, providing an alternative means of low voltage detection, in addition to polling the lvdo bit. the interrupt will only be generated after a delay of t lvd after the lvdo bit has b een set high by a low voltage condition. when the device is powered down the low voltage detector will remain active if the lvden bit is high. in this case, the lvf interrupt request flag will be set, causing an interrupt to be generated if v dd falls below the preset lvd voltage. this will cause the d evice to wake-up from the sleep or idle mode, however if the low voltage detector wake up function is not required then the lvf flag should be first set high before the device enters the sleep or idle mode. scom function for lcd the devices have the capability of driving external lcd panel s. the common pins for lcd driving, scom0~ scom3, are pin shared with certain pin on the pc0~pc1 and pb6 ~ pb7 pins. the lcd signals (com and seg) are generated using the application program. lcd operation an external lcd panel can be driven using this device by config uring the pc0~pc1 or pb6 ~ pb7 pins as common pins and using other output ports lines as segment pins. the lcd driver function is controlled using the scomc register which in addition to controlling the overall on/off function also controls the bias voltage setup function. this enables the lcd com driver to generate the necessary v dd /2 voltage levels for lcd 1/2 bias operation. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 132 february 9, 2011 v d d v l v d l v d e n l v d o t l v d s lvd operation v d d s c o m 0 ~ s c o m 3 s c o m e n c o m n e n v d d / 2 s c o m o p e r a t i n g c u r r e n t lcd com bias
the scomen bit in the scomc register is the overall master control for the lcd driver; however this bit is used in conjunction with the comnen bits to select which port c pins are used for lcd driving. note that the port control register does not need to first setup the pins as outputs to enable the lcd driver operation. scomen comnen pin function o/p level 0 x i/o 0or1 1 0 i/o 0or1 1 1 scomn v dd /2 output control lcd bias control the lcd com driver enables a range of selections to be provided to suit the requirement of the lcd panel which is being used. the bias resistor choice is implemented using the isel1 and isel0 bits in the scomc register. scomc register b i t76543210 name d7 isel1 isel0 scomen com3en com2en com1en com0en r/w r/w r/w r/w r/w r/w r/w r/w r/w por 00000000 bit 7 reserved bit 0: correct level - bit must be reset to zero for correct operation 1: unpredictable operation - bit must not be set high bit 6~5 isel1, isel0 : isel1 ~ isel0: select scom typical bias current (v dd =5v) 00: 25 a 01: 50 a 10: 100 a 11: 200 a bit 4 scomen : scom module control 0: disable 1: enable bit 3 com3en : gpio or scom3 selection 0: gpio 1: scom3 bit 2 com2en : gpio or scom2 selection 0: gpio 1: scom2 bit 1 com1en : gpio or scom1 selection 0: gpio 1: scom1 bit 0 com0en : gpio or scom0 selection 0: gpio 1: scom0 rev. 1.10 133 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
configuration options configuration options refer to certain options within the mcu that are programmed into the device during the programming process. during the development process, these options are selected using the ht-ide software development tools. as these options are programmed into the device using the hardware programming tools, once they are selected they cannot be changed later using the application program. all options must be defined for proper system function, the details of which are shown in the table. no. options oscillator options 1 high speed system oscillator selection - f h : hxt, erc, hirc 2 high speed internal rc frequency selection: 4mhz, 8mhz or 12mhz reset pin options 3 pin function: res or pb3 watchdog options 4 watchdog timer: enable or disable 5 watchdog timer clock source selection: f sub or f sys /4 note: the f sub and the f tbc clock source are the lirc oscillator. 6 clrwdt instructions: 1 or 2 instructions lvr options 7 lvr function: enable or disable 8 lvr voltage: 2.10v, 2.55v, 3.15v or 4.2v application circuits note: * it is recommended that this component is added for added esd protection. ** it is recommended that this component is added in environments where power line noise is significant. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 134 february 9, 2011 "   "   "     1         
            *   $              *  &   $   +  &    +      ?  *    $ ? ?   (  ( @ ?    &     ( &  a #  )  # ( & # a   &  a   &  
instruction set introduction central to the successful operation of any microcontroller i s its instruction set, which is a set of program instruction codes that directs the microcontroller to perform certain operations. in the case of holtek microcontrollers, a comprehensive and flexible set of over 60 instructions is provided to enable programmers to implement their application with the minimum of programming overheads. for easier understanding of the various instruction codes, they have been subdivided into several functional groupings. instruction timing most instructions are implemented within one instruction cy cle. the exceptions to this are branch, call, or table read instructions where two instruction cycles are required. one instruction cycle is equal to 4 system clock cycles, therefore in the case of an 8mhz system oscillator, most instructions would be implemented within 0.5 m s and branch or call instructions would be implemented within 1 m s. although instructions which require one more cycle to implement are generally limited to the jmp, call, ret, reti and table read instructions, it is important to realize that any other instructions which involve manipulation of the program counter low register or pcl will also take one more cycle to implement. as instructions which change the contents of the pcl will imply a direct jump to that new address, one more cycle will be required. examples of such instructions would be 2 clr pcl 2 or 2 mov pcl, a 2 . for the case of skip instructions, it must be noted that if the result of the comparison involves a skip operation then this will also take one more cycle, if no skip is involved then only one cycle is required. moving and transferring data the transfer of data within the microcontroller program is on e of the most frequently used operations. making use of three kinds of mov instructions, data can be transferred from registers to the accumulator and vice-versa as well as being able to move specific immediate data directly into the accumulator. one of the most important data transfer applications is to receive data from the input ports and transfer data to the output ports. arithmetic operations the ability to perform certain arithmetic operations and dat a manipulation is a necessary feature of most microcontroller applications. within the holtek microcontroller instruction set are a range of add and subtract instruction mnemonics to enable the necessary arithmetic to be carried out. care must be taken to ensure correct handling of carry and borrow data when results exceed 255 for addition and less than 0 for subtraction. the increment and decrement instructions inc, inca, dec and deca provide a simple means of increasing or decreasing by a value of one of the values in the destination specified. logical and rotate operations the standard logical operations such as and, or, xor and cpl al l have their own instruction within the holtek microcontroller instruction set. as with the case of most instructions involving data manipulation, data must pass through the accumulator which may involve additional programming steps. in all logical data operations, the zero flag may be set if the result of the operation is zero. another form of logical data manipulation comes from the rotate instructions such as rr, rl, rrc and rlc which provide a simple means of rotating one bit right or left. different rotate instructions exist depending on program requirements. rotate instructions are useful for serial port programming applications where data can be rotated from an internal register into the carry bit from where it can be examined and the necessary serial bit set high or low. another application where rotate data operations are used is to implement multiplication and division calculations. rev. 1.10 135 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
branches and control transfer program branching takes the form of either jumps to specified locations using the jmp instruction or to a subroutine using the call instruction. they differ in the sense that in the case of a subroutine call, the program must return to the instruction immediately when the subroutine has been carried out. this is done by placing a return instruction ret in the subroutine which will cause the program to jump back to the address right after the call instruction. in the case of a jmp instruction, the program simply jumps to the desired location. there is no requirement to jump back to the original jumping off point as in the case of the call instruction. one special and extremely useful set of branch instructions are the conditional branches. here a decision is first made regarding the condition of a certain data memory or individual bits. depending upon the conditions, the program will continue with the next instruction or skip over it and jump to the following instruction. these instructions are the key to decision making and branching within the program perhaps determined by the condition of certain input switches or by the condition of internal data bits. bit operations the ability to provide single bit operations on data memory is an extremely flexible feature of all holtek microcontrollers. this feature is especially useful for output port bit programming where individual bits or port pins can be directly set high or low using either the 2 set [m].i 2 or 2 clr [m].i 2 instructions respectively. the feature removes the need for programmers to first read the 8-bit output port, manipulate the input data to ensure that other bits are not changed and then output the port with the correct new data. this read-modify-write process is taken care of automatically when these bit operation instructions are used. table read operations data storage is normally implemented by using registers. how ever, when working with large amounts of fixed data, the volume involved often makes it inconvenient to store the fixed data in the data memory. to overcome this problem, holtek microcontrollers allow an area of program memory to be setup as a table where data can be directly stored. a set of easy to use instructions provides the means by which this fixed data can be referenced and retrieved from the program memory. other operations in addition to the above functional instructions, a range of o ther instructions also exist such as the 2 halt 2 instruction for power-down operations and instructions to control the operation of the watchdog timer for reliable program operations under extreme electric or electromagnetic environments. for their relevant operations, refer to the functional related sections. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 136 february 9, 2011
instruction set summary the following table depicts a summary of the instruction set c ategorised according to function and can be consulted as a basic instruction reference using the following listed conventions. table conventions: x: bits immediate data m: data memory address a: accumulator i: 0~7 number of bits addr: program memory address mnemonic description cycles flag affected arithmetic add a,[m] addm a,[m] add a,x adc a,[m] adcm a,[m] sub a,x sub a,[m] subm a,[m] sbc a,[m] sbcm a,[m] daa [m] add data memory to acc add acc to data memory add immediate data to acc add data memory to acc with carry add acc to data memory with carry subtract immediate data from the acc subtract data memory from acc subtract data memory from acc with result in data memory subtract data memory from acc with carry subtract data memory from acc with carry, result in data memory decimal adjust acc for addition with result in data memory 1 1 note 1 1 1 note 1 1 1 note 1 1 note 1 note z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov c logic operation and a,[m] or a,[m] xor a,[m] andm a,[m] orm a,[m] xorm a,[m] and a,x or a,x xor a,x cpl [m] cpla [m] logical and data memory to acc logical or data memory to acc logical xor data memory to acc logical and acc to data memory logical or acc to data memory logical xor acc to data memory logical and immediate data to acc logical or immediate data to acc logical xor immediate data to acc complement data memory complement data memory with result in acc 1 1 1 1 note 1 note 1 note 1 1 1 1 note 1 z z z z z z z z z z z increment & decrement inca [m] inc [m] deca [m] dec [m] increment data memory with result in acc increment data memory decrement data memory with result in acc decrement data memory 1 1 note 1 1 note z z z z rotate rra [m] rr [m] rrca [m] rrc [m] rla [m] rl [m] rlca [m] rlc [m] rotate data memory right with result in acc rotate data memory right rotate data memory right through carry with result in acc rotate data memory right through carry rotate data memory left with result in acc rotate data memory left rotate data memory left through carry with result in acc rotate data memory left through carry 1 1 note 1 1 note 1 1 note 1 1 note none none c c none none c c data move mov a,[m] mov [m],a mov a,x move data memory to acc move acc to data memory move immediate data to acc 1 1 note 1 none none none rev. 1.10 137 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
mnemonic description cycles flag affected bit operation clr [m].i set [m].i clear bit of data memory set bit of data memory 1 note 1 note none none branch jmp addr sz [m] sza [m] sz [m].i snz [m].i siz [m] sdz [m] siza [m] sdza [m] call addr ret ret a,x reti jump unconditionally skip if data memory is zero skip if data memory is zero with data movement to acc skip if bit i of data memory is zero skip if bit i of data memory is not zero skip if increment data memory is zero skip if decrement data memory is zero skip if increment data memory is zero with result in acc skip if decrement data memory is zero with result in acc subroutine call return from subroutine return from subroutine and load immediate data to acc return from interrupt 2 1 note 1 note 1 note 1 note 1 note 1 note 1 note 1 note 2 2 2 2 none none none none none none none none none none none none none table read tabrdc [m] tabrdl [m] read table (current page) to tblh and data memory read table (last page) to tblh and data memory 2 note 2 note none none miscellaneous nop clr [m] set [m] clr wdt clr wdt1 clr wdt2 swap [m] swapa [m] halt no operation clear data memory set data memory clear watchdog timer pre-clear watchdog timer pre-clear watchdog timer swap nibbles of data memory swap nibbles of data memory with result in acc enter power down mode 1 1 note 1 note 1 1 1 1 note 1 1 none none none to, pdf to, pdf to, pdf none none to, pdf note: 1. for skip instructions, if the result of the comparison involves a skip then two cycles are required, if no skip takes place only one cycle is required. 2. any instruction which changes the contents of the pcl will also require 2 cycles for execution. 3. for the 2 clr wdt12 and 2 clr wdt22 instructions the to and pdf flags may be affected by the execution status. the to and pdf flags are cleared after both 2 clr wdt12 and 2 clr wdt22 instructions are consecutively executed. otherwise the to and pdf flags remain unchanged. ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 138 february 9, 2011
instruction definition adc a,[m] add data memory to acc with carry d escription the contents of the specified data memory, accumulator and the carry flag are added. the result is stored in the accumulator. operation acc ? acc + [m] + c affected flag(s) ov, z, ac, c adcm a,[m] add acc to data memory with carry d escription the contents of the specified data memory, accumulator and the carry flag are added. the result is stored in the specified data memory. operation [m] ? acc + [m] + c affected flag(s) ov, z, ac, c add a,[m] add data memory to acc d escription the contents of the specified data memory and the accumulator are added. the result is stored in the accumulator. operation acc ? acc + [m] affected flag(s) ov, z, ac, c add a,x add immediate data to acc d escription the contents of the accumulator and the specified immediate data are added. the result is stored in the accumulator. operation acc ? acc + x affected flag(s) ov, z, ac, c addm a,[m] add acc to data memory d escription the contents of the specified data memory and the accumulator are added. the result is stored in the specified data memory. operation [m] ? acc + [m] affected flag(s) ov, z, ac, c and a,[m] logical and data memory to acc d escription data in the accumulator and the specified data memory perform a bitwise logical and operation. the result is stored in the accumulator. operation acc ? acc 2and2 [m] affected flag(s) z and a,x logical and immediate data to acc d escription data in the accumulator and the specified immediate data perform a bitwise logical and operation. the result is stored in the accumulator. operation acc ? acc 2and2 x affected flag(s) z andm a,[m] logical and acc to data memory d escription data in the specified data memory and the accumulator perform a bitwise logical and operation. the result is stored in the data memory. operation [m] ? acc 2and2 [m] affected flag(s) z rev. 1.10 139 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
call addr subroutine call d escription unconditionally calls a subroutine at the specified address. the program counter then increments by 1 to obtain the address of the next instruction which is then pushed onto the stack. the specified address is then loaded and the program continues execution from this new address. as this instruction requires an additional operation, it is a two cy - cle instruction. operation stack ? program counter + 1 program counter ? addr affected flag(s) none clr [m] clear data memory d escription each bit of the specified data memory is cleared to 0. operation [m] ? 00h affected flag(s) none clr [m].i clear bit of data memory d escription bit i of the specified data memory is cleared to 0. operation [m].i ? 0 affected flag(s) none clr wdt clear watchdog timer d escription the to, pdf flags and the wdt are all cleared. operation wdt cleared to ? 0 pdf ? 0 affected flag(s) to, pdf clr wdt1 pre-clear watchdog timer d escription the to, pdf flags and the wdt are all cleared. note that this instruction works in con- junction with clr wdt2 and must be executed alternately with clr wdt2 to have ef- fect. repetitively executing this instruction without alternately executing clr wdt2 will have no effect. operation wdt cleared to ? 0 pdf ? 0 affected flag(s) to, pdf clr wdt2 pre-clear watchdog timer d escription the to, pdf flags and the wdt are all cleared. note that this instruction works in con - junction with clr wdt1 and must be executed alternately with clr wdt1 to have ef - fect. repetitively executing this instruction without alternately executing clr wdt1 will have no effect. operation wdt cleared to ? 0 pdf ? 0 affected flag(s) to, pdf ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 140 february 9, 2011
cpl [m] complement data memory d escription each bit of the specified data memory is logically complemented (1 s complement). bits which previously contained a 1 are changed to 0 and vice versa. operation [m] ? [m] affected flag(s) z cpla [m] complement data memory with result in acc d escription each bit of the specified data memory is logically complemented (1 s complement). bits which previously contained a 1 are changed to 0 and vice versa. the complemented result is stored in the accumulator and the contents of the data memory remain un - changed. operation acc ? [m] affected flag(s) z daa [m] decimal-adjust acc for addition with result in data memory d escription convert the contents of the accumulator value to a bcd ( binary coded decimal) value resulting from the previous addition of two bcd variables. if the low nibble is greater than 9 or if ac flag is set, then a value of 6 will be added to the low nibble. otherwise the low nibble remains unchanged. if the high nibble is greater than 9 or if the c flag is set, then a value of 6 will be added to the high nibble. essentially, the decimal conversion is performed by adding 00h, 06h, 60h or 66h depending on the accumulator and flag conditions. only the c flag may be affected by this instruction which indicates that if the original bcd sum is greater than 100, it allows multiple precision decimal addition. operation [m] ? acc + 00h or [m] ? acc + 06h or [m] ? acc + 60h or [m] ? acc + 66h affected flag(s) c dec [m] decrement data memory d escription data in the specified data memory is decremented by 1. operation [m] ? [m] - 1 affected flag(s) z deca [m] decrement data memory with result in acc d escription data in the specified data memory is decremented by 1. the result is stored in the accu - mulator. the contents of the data memory remain unchanged. operation acc ? [m] - 1 affected flag(s) z halt enter power down mode d escription this instruction stops the program execution and turns off the system clock. the con - tents of the data memory and registers are retained. the wdt and prescaler are cleared. the power down flag pdf is set and the wdt time-out flag to is cleared. operation to ? 0 pdf ? 1 affected flag(s) to, pdf rev. 1.10 141 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
inc [m] increment data memory d escription data in the specified data memory is incremented by 1. operation [m] ? [m] + 1 affected flag(s) z inca [m] increment data memory with result in acc d escription data in the specified data memory is incremented by 1. the result is stored in the accu - mulator. the contents of the data memory remain unchanged. operation acc ? [m] + 1 affected flag(s) z jmp addr jump unconditionally d escription the contents of the program counter are replaced with the specified address. program execution then continues from this new address. as this requires the insertion of a dummy instruction while the new address is loaded, it is a two cycle instruction. operation program counter ? addr affected flag(s) none mov a,[m] move data memory to acc d escription the contents of the specified data memory are copied to the accumulator. operation acc ? [m] affected flag(s) none mov a,x move immediate data to acc d escription the immediate data specified is loaded into the accumulator. operation acc ? x affected flag(s) none mov [m],a move acc to data memory d escription the contents of the accumulator are copied to the specified data memory. operation [m] ? acc affected flag(s) none nop no operation d escription no operation is performed. execution continues with the next instruction. operation no operation affected flag(s) none or a,[m] logical or data memory to acc d escription data in the accumulator and the specified data memory perform a bitwise logical or operation. the result is stored in the accumulator. operation acc ? acc 2or2 [m] affected flag(s) z ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 142 february 9, 2011
or a,x logical or immediate data to acc d escription data in the accumulator and the specified immediate data perform a bitwise logical or operation. the result is stored in the accumulator. operation acc ? acc 2or2 x affected flag(s) z orm a,[m] logical or acc to data memory d escription data in the specified data memory and the accumulator perform a bitwise logical or operation. the result is stored in the data memory. operation [m] ? acc 2or2 [m] affected flag(s) z ret return from subroutine d escription the program counter is restored from the stack. program execution continues at the re - stored address. operation program counter ? stack affected flag(s) none ret a,x return from subroutine and load immediate data to acc d escription the program counter is restored from the stack and the accumulator loaded with the specified immediate data. program execution continues at the restored address. operation program counter ? stack acc ? x affected flag(s) none reti return from interrupt d escription the program counter is restored from the stack and the interrupts are re-enabled by set- ting the emi bit. emi is the master interrupt global enable bit. if an interrupt was pend- ing when the reti instruction is executed, the pending interrupt routine will be processed before returning to the main program. operation program counter ? stack emi ? 1 affected flag(s) none rl [m] rotate data memory left d escription the contents of the specified data memory are rotated left by 1 bit with bit 7 rotated into bit 0. operation [m].(i+1) ? [m].i; (i = 0~6) [m].0 ? [m].7 affected flag(s) none rla [m] rotate data memory left with result in acc d escription the contents of the specified data memory are rotated left by 1 bit with bit 7 rotated into bit 0. the rotated result is stored in the accumulator and the contents of the data mem - ory remain unchanged. operation acc.(i+1) ? [m].i; (i = 0~6) acc.0 ? [m].7 affected flag(s) none rev. 1.10 143 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
rlc [m] rotate data memory left through carry d escription the contents of the specified data memory and the carry flag are rotated left by 1 bit. bit 7 replaces the carry bit and the original carry flag is rotated into bit 0. operation [m].(i+1) ? [m].i; (i = 0~6) [m].0 ? c c ? [m].7 affected flag(s) c rlca [m] rotate data memory left through carry with result in acc d escription data in the specified data memory and the carry flag are rotated left by 1 bit. bit 7 re - places the carry bit and the original carry flag is rotated into the bit 0. the rotated result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc.(i+1) ? [m].i; (i = 0~6) acc.0 ? c c ? [m].7 affected flag(s) c rr [m] rotate data memory right d escription the contents of the specified data memory are rotated right by 1 bit with bit 0 rotated into bit 7. operation [m].i ? [m].(i+1); (i = 0~6) [m].7 ? [m].0 affected flag(s) none rra [m] rotate data memory right with result in acc d escription data in the specified data memory and the carry flag are rotated right by 1 bit with bit 0 rotated into bit 7. the rotated result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc.i ? [m].(i+1); (i = 0~6) acc.7 ? [m].0 affected flag(s) none rrc [m] rotate data memory right through carry d escription the contents of the specified data memory and the carry flag are rotated right by 1 bit. bit 0 replaces the carry bit and the original carry flag is rotated into bit 7. operation [m].i ? [m].(i+1); (i = 0~6) [m].7 ? c c ? [m].0 affected flag(s) c rrca [m] rotate data memory right through carry with result in acc d escription data in the specified data memory and the carry flag are rotated right by 1 bit. bit 0 re - places the carry bit and the original carry flag is rotated into bit 7. the rotated result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc.i ? [m].(i+1); (i = 0~6) acc.7 ? c c ? [m].0 affected flag(s) c ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 144 february 9, 2011
sbc a,[m] subtract data memory from acc with carry d escription the contents of the specified data memory and the complement of the carry flag are subtracted from the accumulator. the result is stored in the accumulator. note that if the result of subtraction is negative, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation acc ? acc - [m] - c affected flag(s) ov, z, ac, c sbcm a,[m] subtract data memory from acc with carry and result in data memory d escription the contents of the specified data memory and the complement of the carry flag are subtracted from the accumulator. the result is stored in the data memory. note that if the result of subtraction is negative, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation [m] ? acc - [m] - c affected flag(s) ov, z, ac, c sdz [m] skip if decrement data memory is 0 d escription the contents of the specified data memory are first decremented by 1. if the result is 0 the following instruction is skipped. as this requires the insertion of a dummy instruc - tion while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation [m] ? [m] - 1 skip if [m] = 0 affected flag(s) none sdza [m] skip if decrement data memory is zero with result in acc d escription the contents of the specified data memory are first decremented by 1. if the result is 0, the following instruction is skipped. the result is stored in the accumulator but the spec- ified data memory contents remain unchanged. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0, the program proceeds with the following instruction. operation acc ? [m] - 1 skip if acc = 0 affected flag(s) none set [m] set data memory d escription each bit of the specified data memory is set to 1. operation [m] ? ffh affected flag(s) none set [m].i set bit of data memory d escription bit i of the specified data memory is set to 1. operation [m].i ? 1 affected flag(s) none rev. 1.10 145 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
siz [m] skip if increment data memory is 0 d escription the contents of the specified data memory are first incremented by 1. if the result is 0, the following instruction is skipped. as this requires the insertion of a dummy instruc - tion while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation [m] ? [m] + 1 skip if [m] = 0 affected flag(s) none siza [m] skip if increment data memory is zero with result in acc d escription the contents of the specified data memory are first incremented by 1. if the result is 0, the following instruction is skipped. the result is stored in the accumulator but the spec - ified data memory contents remain unchanged. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation acc ? [m] + 1 skip if acc = 0 affected flag(s) none snz [m].i skip if bit i of data memory is not 0 d escription if bit i of the specified data memory is not 0, the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is 0 the program proceeds with the following instruc - tion. operation skip if [m].i 1 0 affected flag(s) none sub a,[m] subtract data memory from acc d escription the specified data memory is subtracted from the contents of the accumulator. the re- sult is stored in the accumulator. note that if the result of subtraction is negative, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation acc ? acc - [m] affected flag(s) ov, z, ac, c subm a,[m] subtract data memory from acc with result in data memory d escription the specified data memory is subtracted from the contents of the accumulator. the re - sult is stored in the data memory. note that if the result of subtraction is negative, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation [m] ? acc - [m] affected flag(s) ov, z, ac, c sub a,x subtract immediate data from acc d escription the immediate data specified by the code is subtracted from the contents of the accumu - lator. the result is stored in the accumulator. note that if the result of subtraction is neg - ative, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation acc ? acc - x affected flag(s) ov, z, ac, c ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 146 february 9, 2011
swap [m] swap nibbles of data memory d escription the low-order and high-order nibbles of the specified data memory are interchanged. operation [m].3~[m].0 ? [m].7 ~ [m].4 affected flag(s) none swapa [m] swap nibbles of data memory with result in acc d escription the low-order and high-order nibbles of the specified data memory are interchanged. the result is stored in the accumulator. the contents of the data memory remain un - changed. operation acc.3 ~ acc.0 ? [m].7 ~ [m].4 acc.7 ~ acc.4 ? [m].3 ~ [m].0 affected flag(s) none sz [m] skip if data memory is 0 d escription if the contents of the specified data memory is 0, the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation skip if [m] = 0 affected flag(s) none sza [m] skip if data memory is 0 with data movement to acc d escription the contents of the specified data memory are copied to the accumulator. if the value is zero, the following instruction is skipped. as this requires the insertion of a dummy in - struction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation acc ? [m] skip if [m] = 0 affected flag(s) none sz [m].i skip if bit i of data memory is 0 d escription if bit i of the specified data memory is 0, the following instruction is skipped. as this re - quires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0, the program proceeds with the following in - struction. operation skip if [m].i = 0 affected flag(s) none tabrdc [m] read table (current page) to tblh and data memory d escription the low byte of the program code (current page) addressed by the table pointer (tblp) is moved to the specified data memory and the high byte moved to tblh. operation [m] ? program code (low byte) tblh ? program code (high byte) affected flag(s) none rev. 1.10 147 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
tabrdl [m] read table (last page) to tblh and data memory d escription the low byte of the program code (last page) addressed by the table pointer (tblp) is moved to the specified data memory and the high byte moved to tblh. operation [m] ? program code (low byte) tblh ? program code (high byte) affected flag(s) none xor a,[m] logical xor data memory to acc d escription data in the accumulator and the specified data memory perform a bitwise logical xor operation. the result is stored in the accumulator. operation acc ? acc 2xor2 [m] affected flag(s) z xorm a,[m] logical xor acc to data memory d escription data in the specified data memory and the accumulator perform a bitwise logical xor operation. the result is stored in the data memory. operation [m] ? acc 2xor2 [m] affected flag(s) z xor a,x logical xor immediate data to acc d escription data in the accumulator and the specified immediate data perform a bitwise logical xor operation. the result is stored in the accumulator. operation acc ? acc 2xor2 x affected flag(s) z ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 148 february 9, 2011
package information 16-pin dip (300mil) outline dimensions ms-001d (see fig1) symbol dimensions in inch min. nom. max. a 0.780 ? 0.880 b 0.240 ? 0.280 c 0.115 ? 0.195 d 0.115 ? 0.150 e 0.014 ? 0.022 f 0.045 ? 0.070 g ? 0.100 ? h 0.300 ? 0.325 i ? ? 0.430 symbol dimensions in mm min. nom. max. a 19.81 ? 22.35 b 6.10 ? 7.11 c 2.92 ? 4.95 d 2.92 ? 3.81 e 0.36 ? 0.56 f 1.14 ? 1.78 g ? 2.54 ? h 7.62 ? 8.26 i ? ? 10.92 rev. 1.10 149 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu 1 6 1 9 8 a b c d e f g h i fig1. full lead packages 1 6 1 9 8 a b c d e f g h i fig2. 1 / 2 lead packages
ms-001d (see fig2) symbol dimensions in inch min. nom. max. a 0.735 ? 0.775 b 0.240 ? 0.280 c 0.115 ? 0.195 d 0.115 ? 0.150 e 0.014 ? 0.022 f 0.045 ? 0.070 g ? 0.100 ? h 0.300 ? 0.325 i ? ? 0.430 symbol dimensions in mm min. nom. max. a 18.67 ? 19.69 b 6.10 ? 7.11 c 2.92 ? 4.95 d 2.92 ? 3.81 e 0.36 ? 0.56 f 1.14 ? 1.78 g ? 2.54 ? h 7.62 ? 8.26 i ? ? 10.92 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 150 february 9, 2011
mo-095a (see fig2) symbol dimensions in inch min. nom. max. a 0.745 ? 0.785 b 0.275 ? 0.295 c 0.120 ? 0.150 d 0.110 ? 0.150 e 0.014 ? 0.022 f 0.045 ? 0.060 g ? 0.100 ? h 0.300 ? 0.325 i ? ? 0.430 symbol dimensions in mm min. nom. max. a 18.92 ? 19.94 b 6.99 ? 7.49 c 3.05 ? 3.81 d 2.79 ? 3.81 e 0.36 ? 0.56 f 1.14 ? 1.52 g ? 2.54 ? h 7.62 ? 8.26 i ? ? 10.92 rev. 1.10 151 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
16-pin nsop (150mil) outline dimensions ms-012 symbol dimensions in inch min. nom. max. a 0.228 ? 0.244 b 0.150 ? 0.157 c 0.012 ? 0.020 c 0.386 ? 0.402 d ? ? 0.069 e ? 0.050 ? f 0.004 ? 0.010 g 0.016 ? 0.050 h 0.007 ? 0.010 a 0 ? 8 symbol dimensions in mm min. nom. max. a 5.79 ? 6.20 b 3.81 ? 3.99 c 0.30 ? 0.51 c 9.80 ? 10.21 d ? ? 1.75 e ? 1.27 ? f 0.10 ? 0.25 g 0.41 ? 1.27 h 0.18 ? 0.25 a 0 ? 8 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 152 february 9, 2011 1 6 1 9 8 a a b c d e f g h c '
16-pin ssop (150mil) outline dimensions symbol dimensions in inch min. nom. max. a 0.228 ? 0.244 b 0.150 ? 0.157 c 0.008 ? 0.012 c 0.189 ? 0.197 d 0.054 ? 0.060 e ? 0.025 ? f 0.004 ? 0.010 g 0.022 ? 0.028 h 0.007 ? 0.010 a 0 ? 8 symbol dimensions in mm min. nom. max. a 5.79 ? 6.20 b 3.81 ? 3.99 c 0.20 ? 0.30 c 4.80 ? 5.00 d 1.37 ? 1.52 e ? 0.64 ? f 0.10 ? 0.25 g 0.56 ? 0.71 h 0.18 ? 0.25 a 0 ? 8 rev. 1.10 153 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu 1 6 1 9 8 a b c d e f c ' g h a
20-pin dip (300mil) outline dimensions ms-001d (see fig1) symbol dimensions in inch min. nom. max. a 0.980 ? 1.060 b 0.240 ? 0.280 c 0.115 ? 0.195 d 0.115 ? 0.150 e 0.014 ? 0.022 f 0.045 ? 0.070 g ? 0.100 ? h 0.300 ? 0.325 i ? 0.430 ? symbol dimensions in mm min. nom. max. a 24.89 ? 26.92 b 6.10 ? 7.11 c 2.92 ? 4.95 d 2.92 ? 3.81 e 0.36 ? 0.56 f 1.14 ? 1.78 g ? 2.54 ? h 7.62 ? 8.26 i ? 10.92 ? ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 154 february 9, 2011 2 0 1 1 1 1 0 a b c d e f g h i fig1. full lead packages 2 0 1 1 1 1 0 a b c d e f g h i fig2. 1 / 2 lead packages
mo-095a (see fig2) symbol dimensions in inch min. nom. max. a 0.945 ? 0.985 b 0.275 ? 0.295 c 0.120 ? 0.150 d 0.110 ? 0.150 e 0.014 ? 0.022 f 0.045 ? 0.060 g ? 0.100 ? h 0.300 ? 0.325 i ? 0.430 ? symbol dimensions in mm min. nom. max. a 24.00 ? 25.02 b 6.99 ? 7.49 c 3.05 ? 3.81 d 2.79 ? 3.81 e 0.36 ? 0.56 f 1.14 ? 1.52 g ? 2.54 ? h 7.62 ? 8.26 i ? 10.92 ? rev. 1.10 155 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
20-pin sop (300mil) outline dimensions ms-013 symbol dimensions in inch min. nom. max. a 0.393 ? 0.419 b 0.256 ? 0.300 c 0.012 ? 0.020 c 0.496 ? 0.512 d ? ? 0.104 e ? 0.050 ? f 0.004 ? 0.012 g 0.016 ? 0.050 h 0.008 ? 0.013 a 0 ? 8 symbol dimensions in mm min. nom. max. a 9.98 ? 10.64 b 6.50 ? 7.62 c 0.30 ? 0.51 c 12.60 ? 13.00 d ? ? 2.64 e ? 1.27 ? f 0.10 ? 0.30 g 0.41 ? 1.27 h 0.20 ? 0.33 a 0 ? 8 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 156 february 9, 2011 2 0 1 1 1 1 0 a b c d e f c ' g h a
20-pin ssop (150mil) outline dimensions symbol dimensions in inch min. nom. max. a 0.228 ? 0.244 b 0.150 ? 0.158 c 0.008 ? 0.012 c 0.335 ? 0.347 d 0.049 ? 0.065 e ? 0.025 ? f 0.004 ? 0.010 g 0.015 ? 0.050 h 0.007 ? 0.010 a 0 ? 8 symbol dimensions in mm min. nom. max. a 5.79 ? 6.20 b 3.81 ? 4.01 c 0.20 ? 0.30 c 8.51 ? 8.81 d 1.24 ? 1.65 e ? 0.64 ? f 0.10 ? 0.25 g 0.38 ? 1.27 h 0.18 ? 0.25 a 0 ? 8 rev. 1.10 157 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu 2 0 1 1 1 1 0 a b c d e f c ' g h a
24-pin skdip (300mil) outline dimensions ms-001d (see fig1) symbol dimensions in inch min. nom. max. a 1.230 ? 1.280 b 0.240 ? 0.280 c 0.115 ? 0.195 d 0.115 ? 0.150 e 0.014 ? 0.022 f 0.045 ? 0.070 g ? 0.100 ? h 0.300 ? 0.325 i ? 0.430 ? symbol dimensions in mm min. nom. max. a 31.24 ? 32.51 b 6.10 ? 7.11 c 2.92 ? 4.95 d 2.92 ? 3.81 e 0.36 ? 0.56 f 1.14 ? 1.78 g ? 2.54 ? h 7.62 ? 8.26 i ? 10.92 ? ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 158 february 9, 2011 2 4 1 1 3 1 2 a b c d e f g h i fig1. full lead packages 2 4 1 1 3 1 2 a b c d e f g h i fig2. 1 / 2 lead packages
ms-001d (see fig2) symbol dimensions in inch min. nom. max. a 1.160 ? 1.195 b 0.240 ? 0.280 c 0.115 ? 0.195 d 0.115 ? 0.150 e 0.014 ? 0.022 f 0.045 ? 0.070 g ? 0.100 ? h 0.300 ? 0.325 i ? 0.430 ? symbol dimensions in mm min. nom. max. a 29.46 ? 30.35 b 6.10 ? 7.11 c 2.92 ? 4.95 d 2.92 ? 3.81 e 0.36 ? 0.56 f 1.14 ? 1.78 g ? 2.54 ? h 7.62 ? 8.26 i ? 10.92 ? rev. 1.10 159 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
mo-095a (see fig2) symbol dimensions in inch min. nom. max. a 1.145 ? 1.185 b 0.275 ? 0.295 c 0.120 ? 0.150 d 0.110 ? 0.150 e 0.014 ? 0.022 f 0.045 ? 0.060 g ? 0.100 ? h 0.300 ? 0.325 i ? 0.430 ? symbol dimensions in mm min. nom. max. a 29.08 ? 30.10 b 6.99 ? 7.49 c 3.05 ? 3.81 d 2.79 ? 3.81 e 0.36 ? 0.56 f 1.14 ? 1.52 g ? 2.54 ? h 7.62 ? 8.26 i ? 10.92 ? ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 160 february 9, 2011
24-pin sop (300mil) outline dimensions ms-013 symbol dimensions in inch min. nom. max. a 0.393 ? 0.419 b 0.256 ? 0.300 c 0.012 ? 0.020 c 0.598 ? 0.613 d ? ? 0.104 e ? 0.050 ? f 0.004 ? 0.012 g 0.016 ? 0.050 h 0.008 ? 0.013 a 0 ? 8 symbol dimensions in mm min. nom. max. a 9.98 ? 10.64 b 6.50 ? 7.62 c 0.30 ? 0.51 c 15.19 ? 15.57 d ? ? 2.64 e ? 1.27 ? f 0.10 ? 0.30 g 0.41 ? 1.27 h 0.20 ? 0.33 a 0 ? 8 rev. 1.10 161 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu 2 4 1 1 3 1 2 a b c d e f c ' g h a
24-pin ssop (150mil) outline dimensions symbol dimensions in inch min. nom. max. a 0.228 ? 0.244 b 0.150 ? 0.157 c 0.008 ? 0.012 c 0.335 ? 0.346 d 0.054 ? 0.060 e ? 0.025 ? f 0.004 ? 0.010 g 0.022 ? 0.028 h 0.007 ? 0.010 a 0 ? 8 symbol dimensions in mm min. nom. max. a 5.79 ? 6.20 b 3.81 ? 3.99 c 0.20 ? 0.30 c 8.51 ? 8.79 d 1.37 ? 1.52 e ? 0.64 ? f 0.10 ? 0.25 g 0.56 ? 0.71 h 0.18 ? 0.25 a 0 ? 8 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 162 february 9, 2011 2 4 1 1 3 1 2 a b c d e f c ' g h a
28-pin skdip (300mil) outline dimensions symbol dimensions in inch min. nom. max. a 1.375 ? 1.395 b 0.278 ? 0.298 c 0.125 ? 0.135 d 0.125 ? 0.145 e 0.016 ? 0.020 f 0.050 ? 0.070 g ? 0.100 ? h 0.295 ? 0.315 i ? 0.375 ? symbol dimensions in mm min. nom. max. a 34.93 ? 35.43 b 7.06 ? 7.57 c 3.18 ? 3.43 d 3.18 ? 3.68 e 0.41 ? 0.51 f 1.27 ? 1.78 g ? 2.54 ? h 7.49 ? 8.00 i ? 9.53 ? rev. 1.10 163 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu 2 8 1 1 5 1 4 a b c d e f g h i
28-pin sop (300mil) outline dimensions ms-013 symbol dimensions in inch min. nom. max. a 0.393 ? 0.419 b 0.256 ? 0.300 c 0.012 ? 0.020 c 0.697 ? 0.713 d ? ? 0.104 e ? 0.050 ? f 0.004 ? 0.012 g 0.016 ? 0.050 h 0.008 ? 0.013 a 0 ? 8 symbol dimensions in mm min. nom. max. a 9.98 ? 10.64 b 6.50 ? 7.62 c 0.30 ? 0.51 c 17.70 ? 18.11 d ? ? 2.64 e ? 1.27 ? f 0.10 ? 0.30 g 0.41 ? 1.27 h 0.20 ? 0.33 a 0 ? 8 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 164 february 9, 2011 2 8 1 1 5 1 4 a b c d f c ' g h a e
28-pin ssop (150mil) outline dimensions symbol dimensions in inch min. nom. max. a 0.228 ? 0.244 b 0.150 ? 0.157 c 0.008 ? 0.012 c 0.386 ? 0.394 d 0.054 ? 0.060 e ? 0.025 ? f 0.004 ? 0.010 g 0.022 ? 0.028 h 0.007 ? 0.010 a 0 ? 8 symbol dimensions in mm min. nom. max. a 5.79 ? 6.20 b 3.81 ? 3.99 c 0.20 ? 0.30 c 9.80 ? 10.01 d 1.37 ? 1.52 e ? 0.64 ? f 0.10 ? 0.25 g 0.56 ? 0.71 h 0.18 ? 0.25 a 0 ? 8 rev. 1.10 165 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu 2 8 1 1 5 1 4 a b c d f c ' g h a e
reel dimensions sop 16n (150mil) symbol description dimensions in mm a reel outer diameter 330.01.0 b reel inner diameter 100.01.5 c spindle hole diameter 13.0 +0.5/-0.2 d key slit width 2.00.5 t1 space between flange 16.8 +0.3/-0.2 t2 reel thickness 22.20.2 sop 20w, sop 24w, sop 28w (300mil) symbol description dimensions in mm a reel outer diameter 330.01.0 b reel inner diameter 100.01.5 c spindle hole diameter 13.0 +0.5/-0.2 d key slit width 2.00.5 t1 space between flange 24.8 +0.3/-0.2 t2 reel thickness 30.20.2 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 166 february 9, 2011 a c b t 1 t 2 d
ssop 16s symbol description dimensions in mm a reel outer diameter 330.01.0 b reel inner diameter 100.01.5 c spindle hole diameter 13.0 +0.5/-0.2 d key slit width 2.00.5 t1 space between flange 12.8 +0.3/-0.2 t2 reel thickness 18.20.2 ssop 20s (150mil), ssop 24s (150mil), ssop 28s (150mil) symbol description dimensions in mm a reel outer diameter 330.01.0 b reel inner diameter 100.01.5 c spindle hole diameter 13.0 +0.5/-0.2 d key slit width 2.00.5 t1 space between flange 16.8 +0.3/-0.2 t2 reel thickness 22.20.2 ssop 48w symbol description dimensions in mm a reel outer diameter 330.01.0 b reel inner diameter 100.00.1 c spindle hole diameter 13.0 +0.5/-0.2 d key slit width 2.00.5 t1 space between flange 32.2 +0.3/-0.2 t2 reel thickness 38.20.2 rev. 1.10 167 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
carrier tape dimensions sop 16n (150mil) symbol description dimensions in mm w carrier tape width 16.00.3 p cavity pitch 8.00.1 e perforation position 1.750.1 f cavity to perforation (width direction) 7.50.1 d perforation diameter 1.55 +0.10/-0.00 d1 cavity hole diameter 1.50 +0.25/-0.00 p0 perforation pitch 4.00.1 p1 cavity to perforation (length direction) 2.00.1 a0 cavity length 6.50.1 b0 cavity width 10.30.1 k0 cavity depth 2.10.1 t carrier tape thickness 0.300.05 c cover tape width 13.30.1 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 168 february 9, 2011 p d 1 w p 1 p 0 d e f t k 0 b 0 a 0 c i c p a c k a g e p i n 1 a n d t h e r e e l h o l e s a r e l o c a t e d o n t h e s a m e s i d e . r e e l h o l e
sop 20w symbol description dimensions in mm w carrier tape width 24.0 +0.3/-0.1 p cavity pitch 12.00.1 e perforation position 1.750.10 f cavity to perforation (width direction) 11.50.1 d perforation diameter 1.5 +0.1/-0.0 d1 cavity hole diameter 1.50 +0.25/-0.00 p0 perforation pitch 4.00.1 p1 cavity to perforation (length direction) 2.00.1 a0 cavity length 10.80.1 b0 cavity width 13.30.1 k0 cavity depth 3.20.1 t carrier tape thickness 0.300.05 c cover tape width 21.30.1 sop 24w symbol description dimensions in mm w carrier tape width 24.00.3 p cavity pitch 12.00.1 e perforation position 1.750.1 f cavity to perforation (width direction) 11.50.1 d perforation diameter 1.55 +0.10/-0.00 d1 cavity hole diameter 1.50 +0.25/-0.00 p0 perforation pitch 4.00.1 p1 cavity to perforation (length direction) 2.00.1 a0 cavity length 10.90.1 b0 cavity width 15.90.1 k0 cavity depth 3.10.1 t carrier tape thickness 0.350.05 c cover tape width 21.30.1 rev. 1.10 169 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
sop 28w (300mil) symbol description dimensions in mm w carrier tape width 24.00.3 p cavity pitch 12.00.1 e perforation position 1.750.10 f cavity to perforation (width direction) 11.50.1 d perforation diameter 1.5 +0.1/-0.0 d1 cavity hole diameter 1.50 +0.25/-0.00 p0 perforation pitch 4.00.1 p1 cavity to perforation (length direction) 2.00.1 a0 cavity length 10.850.10 b0 cavity width 18.340.10 k0 cavity depth 2.970.10 t carrier tape thickness 0.350.01 c cover tape width 21.30.1 ssop 16s symbol description dimensions in mm w carrier tape width 12.0 +0.3/-0.1 p cavity pitch 8.00.1 e perforation position 1.750.10 f cavity to perforation (width direction) 5.50.1 d perforation diameter 1.550.10 d1 cavity hole diameter 1.50 +0.25/-0.00 p0 perforation pitch 4.00.1 p1 cavity to perforation (length direction) 2.00.1 a0 cavity length 6.40.1 b0 cavity width 5.20.1 k0 cavity depth 2.10.1 t carrier tape thickness 0.300.05 c cover tape width 9.30.1 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 170 february 9, 2011
ssop 20s (150mil) symbol description dimensions in mm w carrier tape width 16.0 +0.3/-0.1 p cavity pitch 8.00.1 e perforation position 1.750.10 f cavity to perforation (width direction) 7.50.1 d perforation diameter 1.5 +0.1/-0.0 d1 cavity hole diameter 1.50 +0.25/-0.00 p0 perforation pitch 4.00.1 p1 cavity to perforation (length direction) 2.00.1 a0 cavity length 6.50.1 b0 cavity width 9.00.1 k0 cavity depth 2.30.1 t carrier tape thickness 0.300.05 c cover tape width 13.30.1 ssop 24s (150mil) symbol description dimensions in mm w carrier tape width 16.0 +0.3/-0.1 p cavity pitch 8.00.1 e perforation position 1.750.10 f cavity to perforation (width direction) 7.50.1 d perforation diameter 1.5 +0.1/-0.0 d1 cavity hole diameter 1.50 +0.25/-0.00 p0 perforation pitch 4.00.1 p1 cavity to perforation (length direction) 2.00.1 a0 cavity length 6.50.1 b0 cavity width 9.50.1 k0 cavity depth 2.10.1 t carrier tape thickness 0.300.05 c cover tape width 13.30.1 rev. 1.10 171 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu
ssop 28s (150mil) symbol description dimensions in mm w carrier tape width 16.00.3 p cavity pitch 8.00.1 e perforation position 1.750.1 f cavity to perforation (width direction) 7.50.1 d perforation diameter 1.55 +0.10/-0.00 d1 cavity hole diameter 1.50 +0.25/-0.00 p0 perforation pitch 4.00.1 p1 cavity to perforation (length direction) 2.00.1 a0 cavity length 6.50.1 b0 cavity width 10.30.1 k0 cavity depth 2.10.1 t carrier tape thickness 0.300.05 c cover tape width 13.30.1 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu rev. 1.10 172 february 9, 2011
rev. 1.10 173 february 9, 2011 ht66f13/ht66f14/HT66F15 enhanced a/d flash type mcu copyright 2011 by holtek semiconductor inc. the information appearing in this data sheet is believed to be accurate at the time of publication. however, holtek as - sumes no responsibility arising from the use of the specifications described. the applications mentioned herein are used solely for the purpose of illustration and holtek makes no warranty or representation that such applications will be suitable without further modification, nor recommends the use of its products for application that may present a risk to human life due to malfunction or otherwise. holtek s products are not authorized for use as critical components in life support devices or systems. holtek reserves the right to alter its products without prior notification. for the most up-to-date information, please visit our web site at http://www.holtek.com.tw. holtek semiconductor inc. (headquarters) no.3, creation rd. ii, science park, hsinchu, taiwan tel: 886-3-563-1999 fax: 886-3-563-1189 http://www.holtek.com.tw holtek semiconductor inc. (taipei sales office) 4f-2, no. 3-2, yuanqu st., nankang software park, taipei 115, taiwan tel: 886-2-2655-7070 fax: 886-2-2655-7373 fax: 886-2-2655-7383 (international sales hotline) holtek semiconductor inc. (shenzhen sales office) 5f, unit a, productivity building, no.5 gaoxin m 2nd road, nanshan district, shenzhen, china 518057 tel: 86-755-8616-9908, 86-755-8616-9308 fax: 86-755-8616-9722 holtek semiconductor (usa), inc. (north america sales office) 46729 fremont blvd., fremont, ca 94538, usa tel: 1-510-252-9880 fax: 1-510-252-9885 http://www.holtek.com


▲Up To Search▲   

 
Price & Availability of HT66F15

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X